Csla framework trial: Business Object Classification

Source: Internet
Author: User

For example, the title indicates the classification of business objects in the csla framework. At the beginning, it was hard to understand why the objects should be classified, first, describe the methods that people (or within my knowledge) use in the opposite direction.

Generally, objects to be operated are mostly simple objects. Here, simple means that an object can only have single features such as object attributes and object behavior (and some are just data Filling Machines), such as obtaining a customer information, we can only return the entity that encapsulates the customer information data. To obtain the list, we only need to return the list <t>. No matter how the client uses it, we can compare the csla business objects, they lack sufficient intelligence, that is, their respective responsibilities. Alternatively, when using linq2sql or Entity Framework, they have certain intelligence. They can track the object status in the context and easily manipulate the relationship between objects, I also feel that they are common with csla, but for an Orm, perhaps their responsibility is to encapsulate data operations in the form of objects, it is a bit uncomfortable to apply more responsibilities (personal feeling ~). The following are my usage opinions on several types of business objects.

From the perspective of usage, editable objects can be said to be one of the most widely used business objects. From the perspective of name, it can be seen that they are responsible for editing object information. Here, they must be divided into root objects and sub-objects, for objects of different levels, their operations are also different. Taking the root object as an example, the root object has the responsibility to writeCodeGet object information and fill in attribute values from persistence, and the properties exposed to users are encapsulated. What is encapsulated? Data verification, identity verification, Error Tracking, undo tracking, status tracking, etc. When a customer operates an object, these functions are running behind the object. This is also the main function of the root object, the Framework provides developers with methods similar to addbusinessrules to manage authentication information and permission information in a unified manner. For getter and setter of attributes, it is more direct in version 2.0, in the current version, these tasks are encapsulated in the base class. When talking about the sub-editing object, its responsibilities are mostly the same for the root object, but it does not perform operations on the data acquisition of the current object, but receives the ready-made data from the upper-layer object, therefore, it does not use the dataprotal_method method. It only provides local methods for data operations. In the example, we can see that even these data operation methods are operated by the parent object. One problem encountered is the accuracy of object state tracking, especially the attribute assignment during object initialization, which must be completed within the object, in the past, we liked to assign values to the default attributes of new objects because they are not in the State. Here, if the attributes are updated later, the objects have tracked them internally, the Undo operation will be effective, so pay attention to this section...

Another object type that I prefer is the read-only business object list, which is a list type, so it corresponds to a read-only object subtype as its specific information, this type of list service class is mainly used to obtain data and fill in the list items. The rest are business methods, and it does not track the object status (and is not necessary ~), There are no such functions as undo, so the performance will be better, it is more suitable for binding the read-only list. It is better to use static cache for frequently used and slow data updates.

Key-value pairs, which are usually used in many cases, seem to be similar to the read-only object list here, but simplified the type and added several basic query methods. It is quite convenient for simple data. It seems that the data update speed is slower, and the application cache is also very good. Similarly, it is only responsible for object loading and is not as complex as editable objects, or it is the simplest business object, because there may be complicated business methods for List objects.

Command object. This business object should be the most flexible and important business object. Its structure is very simple, but its implementation is very complicated, I feel that such objects make the framework more flexible.

The Parent and Child Relationships mentioned here are not the root objects of the parent object, which need to be clarified. In addition to the objects mentioned above, there are other variants, mainly based on the deformation of the parent-child relationship, but they are also well understood.

I feel that it is difficult to apply these business objects for actual development. The main reason is not because it is not good, nor because it is difficult, but fundamentally, that is to say, there is still a gap between their own object-oriented level and the Object design. If you read DDD, you will find that their ideas have many commonalities. Maybe they are all specific manifestations of object-oriented, from the perspective of object concepts, object relationship processing, and Object Responsibility, I feel that improving my thoughts is the basis for learning and applying them, this is simply the design of business objects on the premise of understanding the business field, so it is closely related to the knowledge of specific fields.

The brain suddenly flashed a ray of light. What we saw in DDD was also very reasonable and suitable for csla applications. That is, the application of this framework was not designed to speed up response, or it should be the application framework when the response speed is not the main purpose.

This is what we think of today. continue next time.
[Add a personal advertisement: Are there any recruiting companies in Beijing? 1.5 years of service, C #, thank you! QQ: 496195435.]

Related Article

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.