Summary of L3 architecture (V)

Source: Internet
Author: User

in this project development, we have made further changes to the previously used layer-3 structure, except for using Castle containers to manage BLL layer and Dal layer, in data encapsulation And reading data is more object-oriented than before.

1, For Bll Layer and Dal The types of layers, which inherit their respective Ibll And Idal, Use Windsor Containers are instantiated in the form of injection, which is the same as the previous one.

2, For Model The layer has some improvements. Every ModelType corresponds to Modelcollection Set type, for example, for orders Order The entity will correspond Ordercollection Object collection type. This set type is inherited from List <t> Type:

Public class ordercollection: List <order>

// List <t>Is a generic type

3. for modelcollection there is only one method in the type, is to convert the read data set to the specified Model object set

4. in Model the definition is also different from the simple data table field encapsulation. Therefore, a small amount of business logic is added. For example:

order , that is to say Ming order and orderdetail is a one-to-many relationship, orderdetail adding an order Object

5, Added the log implementation AOP Idea, use Castle In Facility. aspectsharp Add AttributeTag to intercept messages of method calls in the container. This reduces the number of modifications caused by adding logs after the system is formed.

Experiences in the project:

1, For Layer 3 UI Layer, BllLayer and Dal Write the correspondingCodeIn this project, we often write the code in the business layer to other layers. For example, there is a requirement that users need to reduce the number of items purchased in orders, when you reduce the number of parts, you should use Update Operation. When you reduce the total number of records, delete the corresponding records. I often put this kind of judgment on UI In this project, I realized that UI The layer should only call one method, Bll Layer judgment

UI:Click ()

{

Bll. Update ();

}

Bll:

Update ()

{

If (updateflag)

{

Dal. Update ();

}

Else

{

Dal. Delete ();

}

}

Dal:

Update ();

Delete ();

and, for example, if you have multiple buttons on the interface that are similar to changing the status, for UI layers should be multiple methods, called BLL should also be multiple methods, but Dal the layer should call a method, and should not be changed in the UI layers are assembled.

UI:

Changestatetotrue ()

{

Bll. changestatetotrue ();

}

Changestatetofalse ()

{

Bll. changestatetofalse ();

}

Bll:

Changestatetotrue ()

{

Changestate (true)

}

Changestatetofalse ()

{

Changestate (false)

}

Dal:

Changestate (state)

These problems may not be serious, but the features between layers are clearer, which also helps us conduct horizontal development.

2. there are often many states in the system, extract these States. As a separate project, enumeration can be used for encapsulation to improve code readability and facilitate future users. , and can achieve a unified effect .

3,In the integrated query part of the system, the object class is not used for the transfer of results. Later, I felt that the Integrated Query itself was flexible and variable, and it was difficult to transmit the results using the entity class. In addition, the result set itself is derived from the relationship between multiple entities and entities, and how to transmit it with one entity. Even if an entity is created for each query, how can we deal with future changes?

Some regrets in the project:

get started with Castle : 'Times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> build ORM however, it is a pity that some problems have occurred. Therefore, when writing relationships in entities by yourself, some areas are far-fetched. In the future, we need to learn more.

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.