Architecture Design of Object-lasting Class Framework
Language definition:
1. World: In this article, the world is defined as all system ranges, including database, database record, object instance, object, etc. (noun)
2. Category: Yes, define a set of common feature standards for similar objects, which is manifested as data structure (attributes and relationships) and behavior (operation and). (noun)
3. Object: A entity that is different from other entities by status and behavior, which encapsulates state and behavior, and the state is characterized by relationships and attributes, and behavior is manifested by operation and method. Object is a conceptual entity (that is, reality). (noun)
4. Object metadata: Describe the data group of the object properties, which contains the status of the object data and the state in the persistent mechanism. In this article, it is a set of data that can represent the properties of the object (noun)
5. Attribute object: Object (noun) existing as an object of an object
6. Object Set: A group of objects of the same class. (noun)
7. Example: A specific object exists in memory. (noun)
8. Instantix: Instance of a set of objects. (noun)
9. Database record: The specific object stored in the database (that is, object attributes and relationships) and the object set. For a record or include a set of records (to record the relationship) (noun)
10. Instantiation: Create an object and set its properties and relationships (through database records or other ways). (verb)
11. Object storage: Map the properties of the object to the relationship to database records. (Verbs, nouns)
12. Object reference: If the specific feature of one or several object properties can be obtained in a set of objects (not necessarily an instance), the characteristics of this or several object properties are called Object references. (noun)
13. Program: Program in this article refers to the procedures prepared by Borland's Delphi Object Pascal language. Maybe there is other languages in the text, I will specifically indicate.
Framework concept:
A persistent framework is required to complete the object and the preservation acquisition of the relationship between other objects. It is mainly for the relational database. The purpose is to make the object independently of the database and the data access mechanism, simplify the object-oriented programming, making the object design, Implementation is consistent.
According to "The Design of a Robust Persistence Layer For Relational Databases" [i], and "Implementing Business Objects" expression [ii], "Persistence Brings Success" [iii], "Rolling your own Object Persistence Framework" [iv] of these articles We know that the object itself should be separated and its persistence mechanism can maintain flexibility. So we can lock four problem domains: objects, object metadata, and persistence and mapping mechanisms. (Discussion on the persistence system described above in the above article I will carry out later)
Object
In order to establish a persistent object framework, we must make a unified plan for the general attributes and operations of the object, that is, the properties and operations of the definition object class: l object should have a unique (for the world) ID (ID) Due to the different Id expressions of the database, it may be a character or a number.
l The object can be achieved by a unified Getter / setter mechanism; in other languages, there may be realization of dynamic mapping (reflective mechanism), but in Delphi, I think that the use of reflex mechanisms may lose the consistency of the system design.
l Objects can be operated, loaded, and from the world by being operated by their own metadata objects.
l The object has the following state: new creation (NULL Loading), metadata loading, persistence loading, operation (OPERATING), metadata save (Metadata Save) ), Persistence save, metadata modification (Modify Modify), "MODIFY PERSISTENCE).
Object's metadata
The metadata of the object can be separated by the data instance of the object and the object instance, which can be mapping for the data itself in the memory, and the object can be constructed by data. It is the key to achieving flexible object persistent mechanisms.
The metadata of the object needs:
Describe the properties and data of the object in a universal form.
The properties and data of the object group can be described in the form of a list.
Save the information of the class
Construct objects according to attribute data (also required to save classes)
Persistence
Persistence is divided into: Mapping of objects to persistent mechanisms and objects related to persistent mechanisms.
Persistence should be:
1. Provide a variety of mapping mechanisms, which can be done for text, relational databases.
2. Complete package persistent mechanism, the object only needs to send Save, Retrieve, delete, etc., and can complete your own save, acquisition, delete, etc.
3. Operation of the object for conditions.
4. Provide a relational process mechanism to handle persistence of an inter-object relationship.
5. Provide transaction support, due to attributes, persistence needs: Keep the data of the object attribute, the original data protection of the object attribute; the properties of the synchronization instance and the attribute value in the database (the multitasks in the world).
6. Properly handle the consistency of the instance and other examples in the world (perhaps not on the same machine).
Mapping mechanism
[I] Scott W. Ambler, (November 28, 2000), "The Design of A Robust Persistence Layer for Relational Databases", http://www.ambysoft.com/persistencelayer.pdf
[II] Philip Brown, "Implementing Business Objects", News: //news.borland.com
[III] Joanna Carter, "Persistence Brings Success"