Knowledge of OOAD Based on UML

Source: Internet
Author: User

UML: Unified Modeling Language, which is a unified modeling language. In simple words, it is a particularly useful language. This article is my initial study notes on UML. For cainiao coainiao, it is not possible for us to design, but at least it is necessary to understand it.

I. The so-called Model 1.1 Model is simplified to reality

A model provides a blueprint for the system, but includes a detailed plan. However, the overall plan of the system is taken into consideration to a higher degree. Each system can be described in different ways using an inapplicable model. Therefore, each model is a semantic closed abstract system. The model can be structured, emphasizing the organization of the system. It is also behavioral, emphasizing the dynamic aspects of the system.

1.2 Why modeling?

Someone cloud:Modeling is to better understand the system being developed!

  Through modeling, you can achieve the following goals:

1. The model helps to visualize the system based on the actual situation or the desired style;

2. The model can regulate the structure or behavior of the system;

3. The model provides a template for constructing the system;

4. The model documented the decisions made;

PS:Modeling of a complex system, such as a banking or telecommunications system, becomes more important. If you cannot fully understand a complex system, develop it blindly, and fail it is highly likely.

Ii. Talking about uml2.1 is Shenma UML?

Unified Modeling Language (UML) is a type of drawing software.BlueprintYou can use UML to visualize, detail, construct, and document software-intensive products.

2.2 advantages of UML

1,Visualization: Clear models facilitate communication

2,Details: You can use UML to describe the analysis, design, implementation, and other decisions in detail.

3,Structure: Ing UML descriptions into programming languages

4,Docized: All the details of the system can be described in UML. Such as project plans and release activities.

2.3 application fields

1. Enterprise Information System

2. Banking and financial services

3. China Telecom

4. Defense and aerospace

5. Science

6. Web-based distributed services

Iii. Category chart-Analysis of business model 3.1 categories

A class is a group of object descriptions with the same attributes, operations, relationships, and semantics. A class implements one or more interfaces. Is the graphical representation of the class in:

(1) UML presets four types of visibility: Public, private, protected, and package minus, the plus sign (+) indicates public visibility. It can be seen that all class diagrams in are public.

(2) In UML, the same abstract class and common class are graph representations, but the name is changed to italic, as shown in. After the isabstract attribute is adjusted to true, the class name is changed to italic:

3.2 Relationship

Links are links between things. In object-oriented modeling, there are three important relationships: dependency, generalization, and association.

(1)Dependency

Dependency is a typeUsage relationship, One thing uses another thing. Draw a dependency into a graphDotted line with direction, Pointing to the dependent thing. If the used class changes, the operations of the other class will inevitably be affected. Dependency is reflected in. Net LanguageLocal variable,Method ParametersOrCall static methodsSuch as tools and hammers in real life.

(2)Generalization

In the generalized relationship, the subclass inherits the behavior and meaning of the parent class. The subclass can also add new behaviors and meanings or overwrite the behaviors and meanings of the parent class. On the image, it is generalized intoWith a hollow triangle row pointing to the parent class. Generalization in. NET is an inherited relationship.

(3)Association

  Association isStructure RelationshipIt specifies the relationship between an object and another object.

InterrelatedIt represents a semantic level between two classes or between classes and interfaces.Strong dependencyIs a long-term stable relationship. It is manifested in the Code layer, and appears in the associated class as a class attribute for the associated class, it may also be that the associated class references a global variable of the associated class.

Classa and classb are correlated, and each of them has an attribute of the peer-type instance in the code.

Unidirectional AssociationIt is manifested in the Code layer. For associated Class B, it appears in the form of class attributes in associated Class, it may also be that associated Class A references a global variable of the associated Class B;

Subject is associated with the observer and is a one-to-many relationship. In the code, the subject class will have a set attribute of the observer class object.

Let's take a look at several special associations. They are:

AggregationLink:

Aggregation is a special case of association.Overall and partially owned relationship. At this time, the whole and the part can be separated. They can have their own lifecycles. Some can belong to multiple overall objects or share multiple overall objects, such as cars and engines; it is represented at the code level and is consistent with the association. It can only be distinguished at the semantic level.

CombinationLink:

A combination is also a special case of an association relationship, which is stronger than aggregation and also known as strong aggregation. It also reflects the relationship between the whole and the part, but the whole and the part are inseparable at this time, the end of the overall lifecycle means that part of the lifecycle ends. For example, when a pregnant woman dies, the fetus will naturally die (a bloody example, sorry !); It is represented at the code level and is consistent with the association. It can only be distinguished at the semantic level.

3.3 Interface

An interface is like a contract. The class in charge must be responsible for implementing its public operations and maintaining its public attributes.

3.4 comprehensive case: Company-department-employee relationship

4. use case diagram-describe system behavior

The use case diagram is used to express the services or functions provided by the system, and is suitable for the work in the requirement collection stage.

4.1 Use Cases and executors

In actual design, commonly used use cases are used to express system requirements or behaviors that the system presents externally. The Use Case uses an elliptical graph, and the participant (actor) is a human graph. Because it participates in the operation of the system, there is a connection line between it and the use case.

4.2 inclusion relationship

The include relationship refers to the relationship between two use cases. The behavior of one use case (called the basic Use Case) contains another use case (called the include case). For example, a user-verified use case is included during withdrawal.

4.3 extended relationships

Extended relationships encapsulate a relatively independent and optional action in a basic use case with extension, let it expand from the extension point declared in the base case, so that the behavior of the base case is more concise and the goal is more concentrated. For example, we can print or not print the receipt after the payment is made. This function can be represented by extensions.

5. Activity diagram-one of the key tools for Process Analysis

An activity diagram is usually used to express a series of actions in a business flow, workflow, or system flow. In the early stages of my internship, I often used activity diagrams to draw business processes from demand surveys, and presented activity diagrams to customers to confirm their needs, so that customers can easily understand them. For example, it is a simple login process. If the login fails, the logon page is displayed. If the login succeeds, the logon page is displayed.

PS:Each activity chart can have only one Start Node, but multiple end nodes.

(1)Action

  Activity is the most important component and represents an execution step.

  

(2)Control Flow

  The connection line with arrows is called control flow ). When the source action ends, the control flow starts the target action.

  

(3)Object nodes and object streams

  The object node is a rectangular graph. The object flow graph is the same as the control flow graph.One of the endpoints must be an object node., AndThe other end must be another node. The two endpoints of the control flow cannot be object nodes. Object stream is different from control flow. Object stream can carry data or objects.

  

As shown in, after successful login, we will pass the user's session object to the next node, the next node can use this object.

(4)Decision-making and merger

  In an activity flow, the process intersection is called a merge node ). A merged node hasMultiple Entry lines, but only one exit lineThe figure of the merged nodes is a large hollow rhombus. All the branches that enter the merged nodes will go through the same exit line.

  

The decision node and the merged node share the graph, both of which are large hollow diamond. However, decision nodesThere is only one entry line, but there are multiple exit lines.

  

(5)Forks and connections

ForksIt indicates that a control flow is replaced by two or more control flows. After a fork, these control flows are executed concurrently.

  ConnectionIn contrast to the forks, two or more control flows are replaced by one control flow. To use a forks, you need to use a connection to aggregate the forks into a stream.

(6)Send signals and accept events

  Send signalAn operation can send messages or signals to another activity.

  Accept eventsAn operation is an operation that can be performed only after the message or signal is sent.

As shown in, creating an invoice is a sending signal. Send the invoice message to another activity: collection. Collection is an acceptance event. It can continue to perform subsequent operations only after the invoice is opened.

Vi. Sequence diagram-tool 2 for Process Analysis

A sequence diagram, also known as a sequence diagram, is used to express the interaction between a group of objects in the system.Behavior diagram. The horizontal direction is the object dimension, and the vertical direction is the time dimension. For example, the interaction between pages and actions can be represented by a time sequence diagram. When sending a list request, we need a returned result set.

(1)Lifeline

  Lifeline represents an instance that participates in interaction. The graph shows the dotted line connecting the top rectangle. The rectangle at the top of the dotted line can be placed with the name of the lifeline.

(2)Execution occurred

  An object executes an activity after receiving a message. During execution, it is called execution occurrence. Its graph is a long rectangle.

(3)Message

  The message graph is a line segment with arrows that spans two lifecycles, and objects send messages for interaction.

(4)Termination

The lifeline is born out of life, and stop is used to express the time when the lifeline is terminated. The stop icon is a big cross placed at the bottom of the dotted line of the lifeline, which indicates that the lifeline has been terminated.

References

(1) Zhang chuanbo, fireball-UML war demand analysis, http://www.amazon.cn/tushu/dp/B0079FMI40

(2) Zhou Meng, UML Unified Modeling Language basics, http://wenku.baidu.com/view/28fe7f65ad02de80d4d840ec.html

 

Zhou xulong

Source: http://www.cnblogs.com/edisonchou/

The copyright of this article is shared by the author and the blog. You are welcome to repost this article, but you must keep this statement without the author's consent and provide the original article link clearly on the article page.

Knowledge of OOAD Based on UML

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.