(Synchronized from http://www.blogjava.net/AndersLin/archive/2006/06/15/53086.html)
<Domain driven design> and <patterns of enterprise application architecture> make domain very popular and have aroused wide debate. I am also confused here.
What is a domain model)
I think domain has two meanings: domain object and domain service. What kind of system is a domain-oriented system? What is the difference between a domain object and a common object that complies with the OO principle? What is the difference between a domain service and a common facade or manager object. In terms of concept, a domain object is different from a common object conforming to the OO principle: domain object is in the business sense, it carries business data (I think all domain objects are stateful Objects Based on this). In essence, it comes directly from the real world and has no technical considerations, the "Object conforming to the OO principle" is obtained through OO method analysis and is based on computer technology (such an object can be stateless). But in turn, objects conforming to OO do not necessarily reflect domain objects.
Technically, domain object refers toTransparent and persistent attributes, AndRelated business logic (reflected inUse CaseMedium)OfPojo. Observe the old system carefully and find that both the transaction script and table module operations are data from databases (or other persistent channels). The business logic of transaction is sporadic fragments. The table module operates on the same type of business data set, which contains obvious database traces. A domain object contains the business data that needs to be persisted, all business operations related to it, and has its own inheritance system. Martin Fowler thinks that with these, it can be called a domain object. Therefore, the ORM in its poeaa contains some opaque persistence solutions. I think a real domain object requires a transparent persistence.
Domain service consists of two parts: flow logic and control logic. 1. Business areasProcess logic(Business Process ). A series of business behaviors, including domain object attribute updates, Dao creation, update, and deletion operations, and access to domain service methods including mail and network. 2. Business areasControl Logic(Business rule ). A rule is a declarative statement that applies logic or computation to information values. Business Rule 1. Generate some control information, limit or trigger the execution of certain behaviors; 2. Generate some status information and provide it to the business personnel for reference operations. A rule results either in the discovery of new information or a demo-about taking action ..
Facade or manager is technically considered. In particular, facade generally processes the following logic: 1. communicates with the presentation layer, converts the plane data (VO) of the presentation layer to the domain object associated with it, and converts the calculation result of the domain object to the plane data (VO) return to the presentation layer; 2. the business logic (transaction-oriented) scheduling is completed based on use case, including the domain object and domain service scheduling associated with the business. It may schedule multiple domain services. In simplified conditions, the facade is sometimes equivalent to the service.
If a system is regarded as a mechanical component, domain object is its structure, which is equivalent to the human skeleton, and process logic is power, which is equivalent to the skeleton muscles; the control logic is control, which is equivalent to the nerves in the muscles.
Domain application possibilities
The JavaBean scheme uses SQL mapping and only maps fields. ing of association relations is not supported and there is no polymorphism. However, with the development of the ORM framework, such as Hibernate, domain object becomes possible by providing the ability to support associations and inherit polymorphism.
Cooperation object: Out of Domain Model Domain Model describes an object organization structure and behavior logic for the problem-oriented domain. At the same time, the system also needs to call it a collaboration object to help us deal with specific technical problems.
Architecture of application domain
Domain service | cooperation object
Domain object | (auxiliary object for processing technical issues, including Dao)
Others Domain model exists in various places of the system, but different ing implementations exist in different places. In the general development process, this ing exists in the minds of documents and developers. A ing relationship is presented to the customer. For example, you can allow users to edit the display elements displayed on the page online and use the Object System in Rule definition. In addition, domain leads to different contents in different views. For example, an agent object has only basic attributes in the party view, while some additional information such as assessment records and excellent rate is saved in the sale channel view.