Personal understanding of domain-driven design and the benefits of Git

Source: Internet
Author: User

Note: This article is author original, but can be reproduced freely.

This article is purely personal point of view, Caishuxueqian, improper, please treatise.

First, the field-driven design

Often see everyone in the discussion of this issue, Baidu can also see a lot of related blog. In itself I have not read the relevant books, just spent some of the concepts and the like, may not really understand the concept.

First, the core of domain-driven design is the model, which is to build a domain model. The concept is still deeply recognized. I think that the purpose of domain-driven design is in itself to facilitate understanding and speed up development. The domain model is the modeling of objective facts, not the abstraction, so the model is easy to read and the person who reads the code knows what it means.

As an example:

Assuming that we are now working on a company's internal human resources management System, we will simply model the system.

1  Public class Company2 {3      Public intCompanyID {Get;Set;}4      Public stringCompanyName {Get;Set;}5      PublicList<department> Departments {Get;Set;}6      Public stringAddress {Get;Set;}7      Public stringContact {Get;Set;}8      Public stringPhone {Get;Set;}9     ...Ten}
Company class
1  Public classDepartment2 {3      Public intDepartmentID {Get;Set;}4      Public stringDepartmentname {Get;Set;}5      Public intCompanyID {Get;Set;}6      Public VirtualCompany Company {Get;Set;}7      Public intManagerID {Get;Set;}8      Public VirtualEmployee Manager {Get;Set;}9      PublicList<employee> Employees {Get;Set;}Ten     ... One}
Department Class
1  Public classEmployee2 {3      Public intEmployeeId {Get;Set;}4      Public stringEmployeeName {Get;Set;}5      Public intAge {Get;Set;}6      Public stringGender {Get;Set;}7     ....8}
Employee Class

It is easy to draw such three classes that only the attributes they have are written in the objective fact that the person reading the code can easily get to the point of the person writing the code. In fact, modeling is the design of the database, combined with the code first function of EF, you can directly in the MSSQL set up three tables corresponding to these three classes. In the process of using the system, most of the data in the table is simple to delete and modify, can directly through the domain model to manipulate the data. This greatly improves the speed of development.

But I think modeling like this only works for modeling the real world, and the business is not very complex. If we extract the domain model, but in actual use always need to transform between domain model, DTO, ViewModel, then the structure of the program has actually become the pattern of the transaction script, the transformation between the models has increased the burden of reading and writing code.

Let me give you an example:

Assuming that we are now doing a legendary game with props in the game, then we design an item table, which I personally understand should be similar.

ItemId, ItemType, Attack, Daoshu, MoFa, Defense, Attackrate, Requiredlevel, Requiredattack, Requireddaoshu, Requiredmofa , Sellingprice ....

Props According to ItemType judge whether it is weapons or armor, all the equipment can be based on this table in the game world created. So the armor of the Warrior's heavy armor is not only defensive, but also offensive.

But if designed by the idea of domain-driven design, then it might have a weapon class, armor has a armor class, weapons class in the field should not be defensive, armor class field should not be attacked. This is not easy to expand, the game version of the update to bring new play method is very common, may later be equipped with an enchanting attribute and so on. Abstract database design is better suited for this occasion.

  

Second, the advantages of git

In fact, it happened just before the interview was asked this question. GIT, SVN, TFS is used in the actual production of different companies, SVN is an internship when used to remember, but on their own computer to manage the file. But I still write them in the resume, is purely the number of words.

When I was asked to say that I used code management tools, I said that I think git was better, and then I was asked about Git's advantages over TFS. I thought for a minute didn't want to come up, because I think I have to say a specific case, if the performance is good, fast, it will certainly be asked where performance is good, how fast, and itself such a broad answer has no practical significance. Then I said this problem first put, may be a few minutes more than 10 minutes, in the answer to other questions when the mood is not so nervous to think about this problem, but also really I think of a specific details, and then answered him, the interviewer immediately feel a bright, otherwise I see is ready to let me leave, There's nothing to say ...

In fact, when I answer the interview, he took a computer side in the Baidu ... I went back to try Baidu a bit, Baidu came out of the answer is nothing but good performance, such as the general answer.

I personally think git's most important advantage over TFS is working in parallel.

TFS in the same project, the same file can only be checked out by one person, a check out, and B cannot be modified. If a is responsible for developing the online payment interface, B is responsible for developing user feedback, the two do not have any business relationship, but may have to modify a database configuration file. Before a finished work, B has no way to modify this file for debugging.

Under Git, A and B can modify the same file at the same time, but it takes two people to work together to merge after the change. Makes it possible to work in parallel.

  

  

Personal understanding of domain-driven design and the benefits of Git

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.