In 1980s, as object-oriented technology became a research hotspot, dozens of object-oriented software development methods emerged. Among them, booch, OMT, OOSE and other methods have been widely recognized. However, using different modeling methods is not conducive to communication between developers. While UML unifies the Expression Methods of booch, OMT, and OOSE, and further develops it. In 1997, UML was adopted by OMG as an international object-oriented modeling language.
It incorporates new ideas, new methods, and new technologies in the software engineering field. UML is not limited to supporting object-oriented analysis and design, but also the entire process of software development starting from requirement analysis. Over the past few years, with its concise and clear expression methods and extraordinary expression ability, UML has been widely recognized by the industry! Currently, in the formal development process of most large enterprises, developers generally use UML to establish models. As a software developer, we must learn UML. Because UML is the unified "text", unified "degree", "volume", and "balance", and does not understand UML, as a national of the unified kingdom of software design, it will be difficult and painful.
The composer will make the music in his head into music, and the architect will make the buildings it designs into a blueprint. These music and blueprint are the model ), the process of constructing these models is called modeling ). Software development is like music and architectural design. In the process, it must also present the ideas and results of various workflow processes, such as requirements, analysis, design, implementation, and deployment, this is the modeling of the software system.
So why modeling? The classic answer is: the difference between building a building and building a dog's nest is that building a dog's Nest does not require design. To produce qualified software, you must have a set of specifications on the architecture, processes, and tools.
The current maximum version of UML officially released by OMG is 2.0, which can be downloaded from http://www.uml.org.
UML is composed of graphs and metadata models. graphs are syntaxes and metadata is semantics. UML mainly includes three basic construction blocks: Things, relationships, and diagrams ). In this serialization, we will introduce these basic components of UML, UML tools and applications, so that readers can have a preliminary overall impression on UML. In the next several times of serialization, the content is gradually expanded with several instances.
1.1 Basic constructor of UML
1.1.1 transactions
A thing is the final result of entity abstraction and a basic Member of the model. UML contains structured, behavioral, grouped, and annotated things.
(1) Structured things)
A structured thing is a static part of a model. It is used to present elements of concepts or entities. It is the most common element in software modeling. There are seven types of elements:
Class: A class refers to a set of objects with the same attributes, methods, relationships, and semantics;
Interface: an interface is a service (operation) provided by a class or component. It describes the actions visible to the class or component;
Collaboration: describes a group of classes that collaborate to complete a specific task and their associated sets. It is used to model the use case;
Use Case: A Use Case defines a business goal achieved by the interaction between the executor (the person who interacts with the system outside the system) and the system to be considered;
Active class: An activity class object has one or more processes or threads. The activity class is very similar to the class, but its object represents the behavior of the element and other elements exist at the same time;
Component: A component is a physical and replaceable component that contains a set of interfaces, such as COM + and Java Beans;
Node: A node is a physical element existing in the system during operation. It represents a computing resource and usually occupies some memory and has processing capabilities.
(2) behavioral things)
Action thing refers to the dynamic part of the UML model, which represents the "verb" in the statement and represents the part of the model that changes with time and space. There are two types:
Ineraction: an action is composed of a group of objects in a specific context and a series of message exchanges for a specific purpose;
State Machine: A state machine is composed of the States of a series of objects.
(3) group things)
You can think of grouping things as a "box" in which the model can be decomposed. Currently, there is only one group thing, namely, package ). Structured, action, and even grouped items can all be placed in a package. Packages are purely conceptual and only exist in the development phase, while components exist during runtime.
(4) annotational things)
Annotation is the interpretation part of the UML model.
1.1.2 relationship
A link is a way to link things together. UML defines four relationships:
(1) dependencies: the semantic relationship between two things. Changes in one thing affect the semantics of the other;
(2) Association: Describes the structural relationships between a group of objects, such as the aggregation relationships (describing the structural relationships between the whole and parts );
(3) Generalization: a general-special relationship;
(4) Implementation: The semantic relationship between classes. One Class specifies the contract that is executed by another class.
1.1.3 figure
A graph is a collection of things. UML contains multiple diagrams:
(1) Class digraphs: class diagrams describe the internal structure of the classes and classes contained in the system and the relationship between classes;
(2) object digraphs: an object graph is an instance of a class graph;
(3) package digraphs: Package charts show dependent class diagrams between packages;
(4) compoment divisor (also called component diagram): component diagram descriptionCodeThe physical structure of components and their dependencies;
(5) Deployment diagram (deployment divisor): the deployment diagram defines the physical architecture of software and hardware in the system;
(6) use case diagram (usecase digoal): the use case diagram describes the functions and requirements of the system from the user's perspective, and shows the relationship between various roles outside the system and various internal use cases of the system;
(7) sequence diagram: sequence diagram indicates the dynamic cooperative relationship between objects;
(8) Collaboration digoal: A collaboration diagram describes the relationships between objects;
(9) statechart divisor: A state chart describes all possible states of A Class Object and transfer conditions of the State when an event occurs;
(10) activity diagram: Activity diagram describes the execution sequence of various activities in the system.
The preceding 10 types of images can be classified into five types, for example, table 1.1.
Table 1.1 UML chart Classification
Type |
Include |
Static Graph |
Class diagram, object diagram, and package diagram |
Behavior diagram |
Status chart and activity diagram |
Use case diagram |
Use case diagram |
Interaction Diagram |
Sequence diagram and collaboration Diagram |
Implementation Diagram |
Component diagram and deployment Diagram |
1.2 UML tools and applications
To effectively use UML, we need to obtain a UML tool software first.
Currently, the most widely used UML modeling tool in the industry is Rational Rose. Rational Rose can implement forward (generate corresponding code for the model) and reverse (export the model of the system from the user's original software system) and Bidirectional Engineering (implementing cyclic engineering between models and Code) to ensure high consistency between models and code. Rational Rose supports C ++, Visual C ++, Java, smalltalk, Ada, Visual Basic, PowerBuilder, and other languages and development tools, and can generate an Interface Definition Language (IDL) for the CORBA application ), generate database Description Language (DDL) for database applications. In addition, Rational Rose provides good support for team development and standardized development process management.
For small-scale applications, we can use Visio in Microsoft Office suite, which provides support for drawing various UML diagrams.
From the application perspective, the object-oriented system design generally needs to complete the following work:
(1) Describe the requirement;
(2) establish a static model of the system as needed;
(3) Describe system behavior.
The models created in (1) and (2) are static (use case diagram, class diagram, object diagram, component diagram, and deployment diagram are used ), it is a static modeling mechanism in the standard modeling language UML; and (3) the model created in represents the sequence, state, or interaction during execution (described in the state diagram, activity diagram, sequence diagram, and collaborative drawing). It is a dynamic modeling mechanism in the standard Modeling Language (UML.
It can be seen that the main content of the standard modeling language UML can also be summarized into two categories: Static Modeling Mechanism and dynamic modeling mechanism.
In addition, it should be noted that UML is only a modeling language, which is independent from the specific modeling process. Therefore, any type of modeling process can be followed during modeling. Nevertheless, the authors of UML recommended the Rational Unified Process for us ). The most important features of the Rational Software Company are as follows:
(1) software development is driven by use cases;
(2) software development is centered on architectural design;
(3) software development is an iterative process.
Each stage is divided into several iterations. Each iteration has a core workflow, as shown in Figure 1.1.