One of the Library's surprises (a simple process of establishing a domain model)

Source: Internet
Author: User

One day in college, on a dark night, I came to a gloomy library in the school. Although I didn't like it, I had to give up my books to take the exam. Before arriving at the library counter, I met the librarians. Then I said to the Administrator, "I have borrowed books." The Administrator's hand is not lifted. "The bookshelf is over there and I will find it myself ".

--------------------------------------------------------------------------------

---------------------------------------------------------------------------------

There are a lot of bookshelves. They all put books on the shelves in different categories, each of which has tags that indicate the types of books on the shelves.

---------------------------------------------------------------------------------

---------------------------------------------------------------------------------

So I began to browse some books on the shelves in a row.

---------------------------------------------------------------------------------

---------------------------------------------------------------------------------

When I saw a good book, I took it out and read it.

Bytes ------------------------------------------------------------------------------------------------

Bytes ------------------------------------------------------------------------------------------------

I looked at it and wrote it well. So I took the book to the Administrator: "I want to borrow this book ". The postmaster did not say anything. He took a book and wrote it down. I borrowed the book and tagged it.

Bytes ------------------------------------------------------------------------------------------------

Bytes ------------------------------------------------------------------------------------------------

Then I received this useful book and went back to the Wimbledon test.

 

Certificate -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The above content is just a simulation of a simple example, And the generated class chart is also very rough, we analyze the business behavior (the classic borrowing process is used to analyze the above figure-in order to make it simple, I directly use the vs class diagram, which is not very standard, there are many modeling tools available,The Analysis of Domain Models is not specific, so the models analyzed by everyone may be different.So if you think there are other reasons to draw a different picture, it is completely reasonable.) back to the topic, we will use the domain model to drive our design. However, what we need to understand is what is the analysis of the domain model, where it is suitable, and when it is not suitable.

Domain model is a concept of business modeling. It has nothing to do with software development. Even if an enterprise does not develop software, it has its own business model, the business models of all enterprises in the same industry must have great commonalities and inherent regularity. The business models of enterprises in this industry are then abstracted from the business models of the entire industry, this is the "domain model ". A software company that has mastered the industrial domain model does not need to develop projects for others, and does not need to rely on software development to support itself, you have made a huge profit by providing business consulting to enterprises in this industry.

From this we can see that the analysis of the domain model is not what we need to do when we want to do this software, but when the business model to be implemented by this software appears, we can start, therefore, Domain Modeling is suitable for fields with fixed requirements and mature business models. We first establish a domain model, and then use the simplest and most direct class to implement this model. At this time, we do not involve details such as databases and persistence, and then refine the model. We use the design pattern to break down classes and use several small classes to fulfill the responsibilities of the category of the domain model.

For example, for the user class, we can use the factory mode and the facade mode to decouple the functions and persistent behaviors of the class (the behavior at the data layer.

In fact, DDD does not necessarily represent a bloated entity class, most of the time, we designed a bloated entity class because we were not skilled enough in OO and design patterns (I often developed this kind myself- by restructuring with the design model, in most cases, it can be changed ). As a qualifiedProgramPersonnel, to quickly fulfill the needs is necessary. But if we only want to be able to meet the requirements, isn't the requirement for ourselves too low? We not only need programs that can run, but also stable and robust programs, what's more, there is a beautiful implementation program. If we only want to meet our needs, we can use the sentence of xingye: What are the differences between xianyu and xianyu :)

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.