UML Final Review topic--2.8:uml Design Class Diagram (DCD)

Source: Internet
Author: User

Question eighth: Design class diagram

Key concepts:

1. Class Diagram: Class diagrams are the most commonly used and most important diagrams in object-oriented system modeling and are the basis for defining other diagrams. Class diagrams are primarily used to display a static model of classes, interfaces, and static structures and relationships between them in a system. UML uses class diagrams to represent classes, interfaces, and their associations.

2. Methods that represent the attributes of a class:

A. Attribute text: such as Currentsale:sale

B. Correlation line notation

C. Both have both

Full format for property text notation: visibility name:type multiplicity = default {property-string}

Properties represented by association lines: navigational Arrows + multiplicity (placed at the target end, not one end of the source) + role name (placed only in the target segment to represent the property name) + No association name required

  guideline: You typically use attribute text notation for data type objects , and use association lines for other objects .

3. Descriptive method of the associated endpoint

The associated endpoints can have navigational arrows attached to them, or they can contain optional role names (association end names) to represent the property name.

The associated endpoint can also attach a multiplicity value .

The associated endpoint can also use special strings such as {ordered}, {ordered, list} .

4. Relationships between objects

   A. Dependency (Dependency)

A "use" relationship between entities implies that the specification of an entity changes and may affect other instances that depend on it. More specifically, it can be converted to any type of reference to a class or object that is not within the scope of the instance. This includes a local variable, a reference to an object obtained through a method invocation (as shown in the following example), or a reference to a static method of a class (without an instance of that class). You can also use dependencies to represent the relationship between packages and packages. Because the package contains classes, you can represent the relationship between packages and packages based on the relationships between the classes in those packages.

   B. Association (association)-One-way Association, bidirectional Association, Multidimensional Association, Self-Association

A structured relationship between entities indicates that objects are interconnected. The arrows are optional and are used to specify navigation capabilities. If there are no arrows, hinting is a two-way navigation capability. In Java, the association is converted to an instance-scoped variable, just as the code shown in the Java area of Figure E. Additional modifiers can be attached to an association. The multiplicity (multiplicity) modifier implies a relationship between instances. In the model code, an employee can have 0 or more timecard objects.  However, each timecard only belongs to a single employee. One-way association: A solid arrow indicates a two-way association: a solid line without an arrow indicates a multidimensional association: The Correlation Center has a ◇ (diamond), solid line without arrows to connect to indicate its own association: starting from itself, back to itself

   c. Aggregation (Aggregation)-strong correlation, which will not fail after a partial departure from the whole

An aggregation is a form of association that represents a two-classOverall/local relationship。aggregation implies that the whole is conceptually at a higher level than the local, and the association implies that two classes are conceptually at the same level. Aggregations are also converted to an instance-scoped variable in java.

The difference between association and aggregation is purely conceptual, and is strictly reflected in semantics. Aggregation also implies that there are no loops in the instance diagram. In other words, it can only be a one-way relationship.

   d. Synthesis (composition)-Stronger association relationships, which fail after partial departure from the whole

Synthesis is a special form of aggregation,imply "partial" lifetime responsibilities within the "whole"。 The composition is also unshared. Therefore, although the local does not have to be destroyed with the overall destruction, but the overall responsibility to maintain a local survival, or be responsible for destroying it.

Local cannot be shared with other whole. However, the whole can transfer ownership to another object, which will then assume the lifetime responsibility. The relationship between employee and timecard may be better represented as "compositing" rather than "associative".

   E. Generalization (generalization)--Inheritance relationship

Generalization represents a relationship between a more generalized element and a more specific element. Generalization is used toInheritanceThe UML elements that are modeled. In Java, this relationship is represented directly by the extends keyword.

   F. Implementation (realization)--Interface implementation

An instance relationship specifies a contract between two entities. In other words, one entity defines one contract and another entityensure that the contract is fulfilled。 When modeling a Java application, the implementation relationship can be expressed directly with the Implements keyword.

  An interface is a special class that has the structure of a class but cannot be instantiated and can only be implemented (inherited). There are two representations of interfaces in UML class diagrams: The rectangular notation (the Flying interface in 2) and the Lollipop notation (-2 in Donald Duck class to achieve the spoken interface). rectangular notation with << interface at the top >> or <<interface>>, first line: interface name, second line: interface method. Lollipop notation , the interface name next to the circle, the interface method appears in the implementation class, such as the speech in Donald Duck class.

5. Constraints

A UML constraint is a restrictive condition on a UML element. Constraints are expressed as text between curly braces, such as {size>10}

The constraint on the property, written behind the property. The constraint on the operation, written in the form of a comment or a post condition. But you have to have {}.

 

Draw points:

Specific method: http://www.cnblogs.com/riky/archive/2007/04/07/704298.html

Http://www.uml.org.cn/oobject/201104212.asp

Http://www.cnblogs.com/silent2012/archive/2011/09/07/2169946.html

Http://developer.51cto.com/art/201007/209503.htm

Implementation example: HTTP://BLOG.CSDN.NET/FLANET/ARTICLE/DETAILS/7746004

According to the example, it is very good to understand the knowledge points that need to be skillfully used in the class diagram.

 

Precautions:

  1. Drawing steps

First copy the class in the sequence diagram.

Then look at the domain model, copy the domain model to the properties of the class that should be here, and then make the link in the domain model into the implementation.

Methods for supplementing classes.

The number of controller class methods can only be the same as the number of previous system events, and how many methods can be written by system events.

1) in front of the Has,own this association can not be left, if left, the deduction, should be the concept class diagram of the association to have an arrow no text (or there is text at the associated end point) of the expression

2) multiplicity to maintain

3) do not write what set method, get method, this is the problem of programming, not the problem here

  2. Be sure to correspond to the interaction figure one by one

The method and the object all must correspond!!

  In 3.Domain, put everything except the UI and the controller.

Determine the properties, dependencies, and implementations of each object individually.

Draw relationships between objects in domain (methods of existence)

  4. Domain model = = "Conceptual Perspective"

   Design Model (DCD) = = "Software Perspective"

Answers to questions:

UML Final Review topic--2.8:uml Design Class Diagram (DCD)

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.