Current location - Training Enrollment Network - Books and materials - How to draw classes using Enterprise Architect
How to draw classes using Enterprise Architect
Drawing Class Diagram with Enterprise Architects

1. Select File-New Project, select a location, and then click Save.

Figure 1:

Second, in the model selection window that pops up, you can select the category here.

Figure 2:

Third, the template is only a reference case. Here, you can create a default package by clicking the new package on the right instead of using a template.

Figure 3:

Fourth, you can create a master chart in the package.

Figure 4:

5. After creating a chart, it will generally open by default. If it doesn't open by default, right-click on the chart to open it directly, as shown in the figure.

6. Note that the packages and the diagrams and classes of each package are now started. If the project is not big, directly build the class, and then directly establish the relationship. If the project is large, packages will be built, and all packages will be built in the main diagram, as shown in the following figure:

Seventh, click OK and a new chart window will pop up. The common name is the same as the package name. Just confirm it directly, as shown in the following figure:

9. After confirmation, the package is built. Next, create each package and the main graph in each package. When finished, it looks like this:

X. Now double-click the package in the main diagram, and you can directly enter the main diagram in the package, where you can create various classes and interfaces. If the class relationship can be completed in the package, it can be done directly in the package. If multiple packages are involved, it is generally recommended to complete them in the main diagram. In the main diagram, you can't directly see the individual classes in other packages, only the packages and the classes contained in them. If you want to draw a class diagram in the main diagram, you can only drag the classes in the package to the main diagram by dragging.

The following are the completed packages and classes:

XI。 Now, it is necessary to add a relationship to the table in Main main.

There are many well-described relationships, so I won't explain them here. Here I mainly talk about how to draw class relationships in Enterprise Architect.

First, drag each class to be associated into the main diagram. If you don't need to associate with other packages, just do it directly in the main picture in the package. Note: When dragging, a dialog box will pop up asking the type of dragging. Generally choose the first one and drag it in as a link, as shown in the figure below:

Second, in left-handed relationships, only basic relationships are generally provided. You can put off a relationship before you change it. Here, right-click directly in the blank space to create a dependency:

After clicking, drag directly between classes to complete the establishment of dependency.

The English for each relationship is as follows:

Dependency, from the dependent to the dependent.

Relationship.

Directional association has a directional relationship.

Aggregation aggregation

Synthesis/synthesis

Nested nested inner class

Generalized relation

Realize implementation

Lenovo can refer to:

http://blog.csdn.NET/gfdonx/article/details/4953953 1

General situation of dependency:

The first and most commonly used method is to take the object of one class as the parameter of the method of another class.

The second method is to use the object of another class as its local variable in the method of one class. (Note here that if a variable is mentioned in the attribute, it becomes a one-way relationship. )

The third way is to call the static method of another class in the method of one class.

Scenario of relationship:

It is a structured relationship, which is used to indicate that there is a connection between one class and another.

(1) bidirectional association

For example, a customer buys a product and owns it. On the contrary, there is always a customer associated with the product sold.

(2) one-way correlation

Usually one-way association takes the object of one class as the member variable of another class.

(3) autocorrelation

In the system, there may be some classes whose attribute object type is the class itself. This special association is called self association.

(4) Multiple correlation

Multiple relationships, also known as multiple relationships, represent the quantitative correspondence between two related objects.

General situation of aggregation relationship:

Aggregation represents the relationship between the whole and the parts. In the aggregation relationship, the member object is a part of the whole object, but the member object can exist independently of the whole object. Aggregation is the property that one object is another. When code implements aggregation, member objects are usually injected into the whole object as parameters of constructor, Setter or business method.

General situation of combinatorial relationship:

Combinatorial relationship also represents the whole and local relationship between classes, but in combinatorial relationship, the whole object can control the life cycle of member objects. Once the whole object does not exist, the member object does not exist, and the member object is related to the whole object. And some objects can't exist alone. Or existence is meaningless. The creation of member objects is also completed in the whole object.

General situation of generalized relation:

Generalization relationship, that is, inheritance relationship, is used to describe the relationship between parent class and subclass. A parent class is also called a base class or a superclass, and a subclass is also called a derived class.

General scenario of that relationship between interface and implementation:

Interfaces can also have inheritance and dependency relationships similar to those between classes, but there are also implementation relationships between interfaces and classes. In this relationship, the class implements the interface and the operations in the class implement the operations declared in the interface.

Import of code engineering

First, if you have written the code, you can choose to right-click the main package, code project, and import source files and directories.

Second, you need to create a class relationship through imported code and classes created through EA. Some imported class relations have been drawn, but they are not perfect, and the imported class diagram only has the relations within the package, but not across the package.