In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what is the concept and function of domain model". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The concept and function of Domain Model
A domain model is a visual representation of conceptual classes in a domain or objects in the real world. Also known as conceptual model, domain object model, analytical object model. It focuses on analyzing the problem domain itself, discovering important business domain concepts, and establishing relationships between business domain concepts. The concept is more esoteric, but to put it bluntly, we draw a class diagram based on our understanding of the business, and draw the relationship between these classes (object-oriented).
The domain model can sort out the concepts and relationships in the business, help the members of the team to have a consistent understanding of the business, and then guide database design, system function design and development. In the whole system construction cycle, it can play the role of connecting the demand and continuing the development.
Since the domain model is so important, should we show the properties and methods of the object as much as possible in the class diagram in order to better guide the follow-up development and design?
On the contrary, we should not focus on attributes or behavior when modeling, we should get rid of these details, grasp the most basic characteristics of domain object definition, and only need to reflect the important concepts of the object model. If there are too many details, it is easy to "see only the trees, not the forest".
Let's take a look at a simplified domain model of the reimbursement business to deepen our impression.
To complete a domain model, you need to do two main things:
Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community
Define the key properties and behaviors of a class
Define the relationship between classes.
Define the properties and behavior of a class
It's easy to define the properties and behaviors of a class, just drag a class with the designer, and you only need to pay attention to the access permissions for the properties and behaviors.
-for private # for protected ~ for default, that is, package permission + means public
Define the interaction between classes
In the UML class diagram, the relationships among six categories are defined, they are: Generalization, Realization, Association, Aggregation, Composition, Dependency. There are many relationships, and some of them are quite similar, such as aggregation and combination. Next, we will gradually explain:
Generalization (Generalization)
Introduction:
Generalization represents the inheritance relationship between classes, and between interfaces.
Legend:
Represented by hollow triangles + solid lines.
Code implementation:
Public class A {} public class B extends A {}
Implement (Realization)
Introduction:
An implementation (Realization) represents a class class that implements the functionality of interface interfaces (which can be multiple).
Legend:
Represented by hollow triangles + dashed lines.
Code implementation:
Public interface A {} public class B implements A {}
Aggregation (Aggregation)
Introduction:
Aggregation represents a weak 'ownership' relationship, that is, the relationship of has-a, which reflects that An objects can contain B objects, and the life cycle of class B objects can not depend on the life cycle of class An objects, that is, class An objects can be destroyed separately without affecting class B objects, such as the relationship between courses and students.
Legend:
Represented by a hollow diamond + solid line arrow.
Code implementation:
Public class A {private B b; public A (BB) {this.b = b;}}
Combination (Composition)
Introduction:
Composition represents a strong 'ownership' relationship, that is, the relationship of contains-a, which reflects that An object contains B object, the life cycle of B object depends on the life cycle of An object, and B object can not exist alone, such as the relationship between bird and wing.
Legend:
Use solid diamond + solid line arrows, and you can also use numbers at both ends of the connection to indicate how many instances there are at one end.
Code implementation:
Public class A {private B b; public A () {this.b = new B ();}}
Association (Association)
Introduction:
Association is a very weak relationship, including aggregation and combination. For two relatively independent objects, when one object is responsible for constructing an instance of another object, or relying on the services of another object, the relationship between the two objects is mainly a dependency. At the code level, if class B is a member variable of class A, then class B and class An are associated.
Legend:
Represented by solid-line arrows.
Code implementation:
Public class A {private B b; public A (BB) {this.b = b;}}
Or
Public class A {private B b; public A () {this.b = new B ();}}
Dependency (Dependency)
Introduction:
Dependency is a relationship that is weaker than association, including association. Whether class B objects are member variables of class An objects, or class A methods use class B objects as parameters or return values or local variables, as long as there is any usage relationship between class B objects and class An objects, we say they have dependencies.
Legend:
Indicated by a dashed arrow.
Code implementation:
Public class A {private B b; public A (BB) {this.b = b;}}
Or
Public class A {private B b; public A () {this.b = new B ();}}
Or
Public class A {public void func (BB)...} Model Simplification
Strict UML class diagrams split the relationship between too fine, professional requirements are very high, greatly increasing the cost of learning, and for business communication, guide the follow-up database design, programming development does not have much significance.
Therefore, in the actual business modeling process, we do not need to strictly follow the interaction of UML class diagrams to describe the relationship between business entities. For example, we can represent aggregation, composition and association with association relations, connect two entities with solid lines, and mark the number of instances on both sides.
This is the end of the content of "what is the concept and function of domain model". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.