UML Class Diagrams < go >

Source: Internet
Author: User

UML class Diagram    interpreting UML Class diagrams:1.        First look at the "animal" rectangle, which represents a class. The class diagram is divided into three layers, the first layer shows the name of the class, and if it is an abstract class it will be displayed in italics. The second layer is the attribute of the class, usually the fields and attributes. The third layer is the operation of the class, usually the method and behavior. Note that the preceding symbol, ' + ' indicates public, '-'   denotes private, ' # ' represents protected.                                                 2.        the "Fly" rectangular box represents an interface diagram, which differs from the class diagram in that the top has the interface display, the first line is the interface name, and the second line is the interface method. Interface there is another way to express, commonly known as lollipop notation, Donald Duck class to achieve the "speaking" interface.                                 &NBSP ;                          ,         &NB Sp                                  interface ifly                                 interface Ilanguage                               
{                                             {
void Fly (); void Speak ();
}                                             }
3. Animals, birds, ducks, Donald Duck they are both inherited relationships,Hollow triangle + solid lineTo express. 4. "Wild Goose" realizes the "Fly" interface. Implement interfaces withHollow Triangles + dashed lines to indicate。 (Note: The following figure should be a hollow triangle) class Bird:animal class Widegoose:ifly
{                                       {
Inherit the animal class//Realize the Flying interface
}                                       }
5. Penguins have a great relationship with the climate, and penguins need to "know" the climate change and need to "understand" the climate law. When a class "knows" another class, an association (association) relationship can be used.The Association relationship is represented by a solid arrow. Class Penguin:bird
{
Private Climate climate;//in Penguin Penguin, referring to the climate Climate object
}
6. Two classes of "Wild Goose" and "Wild Goose herd". Wild geese are social animals, each goose belongs to a flock of geese, a flock of geese can have more than a wild goose. So the aggregation (Aggregation) relationship is satisfied between them. Aggregation represents a weak "owning" relationship, which reflects that a object can contain a B object, but the B object is not part of a object.The aggregation relationship is represented by a hollow diamond + solid arrow。 Class Widegooseaggregate
{
Private widegoose[] Arraywidegoose;
In the Widegooseaggregate class of wild geese, there are wild Goose array objects Arraywidegoose
}
7. "Birds" and "wings" of the two classes. Birds and wings resemble the whole and part of the relationship, and the wings and the life cycle of the bird are the same, where the bird and its wings are synthetic relations. Synthesis (composition) is a strong "owning" relationship that embodies a strict part-to-whole relationship, as part of the life cycle of the whole.synthetic relationships are represented by solid Diamond + solid arrows。 In addition, there is a number "1" and a number "2" on both ends of the composite connection, which is called the cardinality. Indicates that the class on this end can have several instances, and it is clear that a bird should have two wings. If a class can have countless instances, it is represented by "n".   Associative relationships, the aggregation relationship can also have cardinality. Class Bird
{
Private Wing wing;
Public Bird ()
{
Wing=new Wing ();
In the bird Bird class, when initialized, the wing wing is instantiated, and both of them are generated simultaneously
}
}
8. Between "Animal", "oxygen" and "water". Animals have several major characteristics, such as metabolism, can reproduce. And animals need to have life, oxygen, water and food. In other words, animals depend on oxygen and water. Between them isDependency (Dependency), denoted by a dashed arrow。 Abstract class Animal
{
Public metabolism (Oxygen oxygen,water water)
{
}
} Transferred from: http://www.cnblogs.com/yangfengming/archive/2008/08/14/1267495.html

UML Class Diagrams < go >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.