Correct understanding of using class diagrams in UML-two forms of analyzing class diagrams

Source: Internet
Author: User

Summary
This article briefly analyzes and designs an example of a "Student Course Selection System" to illustrate the two functions and forms of a class diagram in a UML diagram, in order to clarify the misunderstandings and confusions that some friends may have on class diagrams.

Preface
With the popularity of OOA and OOD, UML has been widely used in system analysis and design. In the nine types of UML diagrams, class diagrams are the most important and commonly used diagrams. However, during chats with some friends, especially beginners, I found that many of my friends have some misunderstandings and confusions about the role and usage of class diagrams. So I wrote this articleArticleTo some extent, I hope this article will help these friends better understand and use class diagrams. Of course, because I do not have a deep understanding of UML, I would like to ask you to criticize and correct the mistakes and omissions in this article.

A vs D
To correctly understand and use class diagrams, we must first understand two concepts: "A" and "D ".
A is the abbreviation of analyse, that is, what we call "analysis", and D is the abbreviation of design, that is, "design ". Generally, a system requires two steps: Analysis and Design before coding. The vague understanding of these two concepts is the reason why many friends cannot correctly use class diagrams.
Analysis: Based on the user's needs, make a series of sorting and identification irrelevant to the business field and computer technology.
Many of my friends have a wrong idea that software development must be done by people who know computers. How can people who do not know computers develop software? Of course, this is the case for design, coding, and other work, but only "analysis" can be done by people who do not fully understand computers, or to some extent, people without knowledge of computers are more suitable for software analysts. If you want to do a good job of analysis, you must only be related to the business, rather than the specific technology. A brain-filled computer technology Program When people perform analysis, they can easily think of details such as coding, implementation, platform, and database design. This form of thinking has become the biggest obstacle for analysis. This is Misunderstanding 1: only people who know computer technology can be system analysts. My current Research Institute (Institute of software engineering, Institute of Computer Science, Beijing University of Aeronautics and Astronautics) once took over a Japanese project. At that time, a system analyst sent from the Japanese side was completely a layman in computer science, it is a field expert, but he has done a good job in system analysis.
Another misunderstanding is that UML diagrams, especially class diagrams, are used by developers. Many people think that UML is a specialized language in the computer industry. How can we use it without understanding it? What does it do? However, many system analysts who do not understand computers are also using UML diagrams for analysis, and class diagrams are one of them. In general, analysts do draw a set of class diagrams during analysis. However, the class diagram it draws is different from the class diagram made by the designer from the perspective or function. The details are described below. This is Misunderstanding 2: only computers use UML diagrams.
The analysis is complete. The design is described below. Different from analysis, My interpretation of the design is: Based on the analysis materials and technology platform, determine the architecture structure, coding method of the software system and all macro problems related to specific technologies.
It can be seen that, unlike design and analysis, it must be done by people on the computer side, because it is closely related to specific technologies. In addition, designers will also draw a set of class diagrams during design.
Here, we have made it clear that the original software will draw a set of class diagrams in both the analysis and design stages, which are drawn by two different roles of analysts and designers. So what are the similarities and differences between the two types of graphs? The following explains the problem.

Domain class diagram vs implementation class diagram
As mentioned above, two types of diagrams are generated by two roles during software analysis and design. Generally, the class diagrams drawn by analysts are called "Domain class diagrams", while the class diagrams drawn by designers are called "implementation class diagrams ". Here we should declare that these two terms are my habitual sayings, and they are not common sayings that everyone agrees. Below, I will define these two types of graphs:
Domain charts: these charts are generated in the analysis phase and are drawn by system analysts. They mainly describe the static structure of business entities, this includes the business attributes and operations of business entities and the relationships between business entities.
Although this class chart is also called a class chart, to be honest, it has nothing to do with the "class" in programming, because there may be no classes in the final system that correspond to them at all, in addition, many classes in the final system, such as the control class and interface class, do not exist in this class diagram. That is to say, this set of diagrams has nothing to do with specific technologies. It is not shown to programmers. It only expresses a static structure in the business field. The following is an example:

This is a simple domain analysis class diagram of the Course Selection System. As you can see, the main entities include teachers, students, courses, and course classes. Each entity marks its business attributes and methods. The graph also shows the relationship between entities.
However, in the end, no student category may correspond to it. This is because the classes, attributes, and methods in the system depend on the selected platform and architecture. For example, if struts2 is used, there will be many action classes, and ASP is used. net MVC, there will be many controller classes, so the domain class diagram is only related to the business and has nothing to do with the specific implementation and coding and other computer technologies.
The following describes the implementation class diagram:
Implementation class diagram: it is generated in the design stage and drawn by the system designer. Its role is to describe the architecture structure of the system and guide programmers to code. It includes all entity, control, interface, and all technical information related to a specific platform that is necessary to be specified in the system.
Like the above field class diagram, if you give it to the programmer code, I think the programmer will go crazy, because it does not provide any coding basis. Suppose we are using.. NET platform, and use ASP. net MVC, the designer should plot all entity classes, data classes, business logic classes and interface classes in the implementation class diagrams. The interface classes are divided into view classes and controller classes, IOC, AOP, and other information should also be displayed, and the attributes and methods of each class should not be omitted, because the basis for the ultimate programmer to implement the Program is to implement the class diagram.

Summary
Finally, let's summarize the main points of this article:
1. Software analysis and design are the first two phases of coding. The analysis is only related to the business, but not the technology. The design is based on analysis and mainly related to specific technologies.
2. In the analysis phase, analysts draw domain class diagrams, and in the design phase, designers draw implementation class diagrams.
3. the domain class diagram indicates the static domain structure of the system. The classes do not correspond to the classes in the final program. The design class diagram indicates the technical architecture of the system, which is the coding basis of programmers, the class corresponds to the class in the system.
4. The attributes and operations of a class in a domain class diagram only focus on the business-related aspects. The attributes and operations in a class diagram must include all the methods and operations that need to be implemented.

I hope this article will help you!

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.