Engine-Collection-Class, a design pattern for establishing reusable enterprise components

zhaozj2021-02-11  187

Mike McClure

Microsoft Corporation

Leo Romanosierra System Group Inc. August 2000

Summary: Detailed description of a way to design reusable enterprise components. This article focuses on Engine-Collection-Class (ECC) design mode, which creates a flexible model for distributed / hierarchical applications, which can be both along with traditional "fat" clients. Work, you can work with the script client.

Download the Desipat.exe sample file (1.46 MB).

table of Contents

Introduction Prerequisitational Overview Development Solution Engine-Collection-Class Design Overview Reviews Note Conclusions Reference

Introduction

This article details a method for designing reusable enterprise components. Focus on discussing a confirmed design pattern, which has been implemented by multiple projects and customers, and has been improved.

Engine-Collection-Class (ECC) Design mode is a flexible model for creating reusable enterprise components for distributed / hierarchical applications, which can work with traditional "fat" clients, or The increasingly popular script client works together. Since it has a simplified interface and intuitive coding style, the ECC design mode shortens the development time and allows multiple developers to implement consistent programming. The company and developers can utilize its scalability while achieving future enhancements and utilizing its maintenanceability when supporting an application.

Because the core of this design mode is based on COM and other popular design patterns, ECC can be implemented either the object-oriented language, or the use of components can also be used. This article focuses on discussing the Microsoft® Visual Basic® implementation of ECC design patterns.

Prerequisites

This article is mainly an primary reading of Engine-Collection-Class, and some of the more advanced features of ECC design model are not discussed in detail.

To effectively use ECC design patterns, it is recommended to first meet the following essential conditions:

There is a basic understanding of the N-layer architecture and design, including Microsoft Windows® DNA and the functions of each layer. The concept of COM and how Visual Basic implement it has basic understanding. There is a basic understanding of the concept of face-to-object. There is a basic understanding of the component design, including the purpose of the object, the concept of loosely coupled coupling, and the separation of the interface and implementation. There is a basic understanding of the database design - knowing the entity relationship map (ERD) and how to use them in database design. Agree to the following perspectives: If the various factors that make decisions have led to unflexible design, many system design will be very flexible. ECC design patterns take into account this situation and use a flexible implementation to reduce the cost of these decisions. Note: For a list of works and articles for further elaboration, see the reference part.

Overview

Whether you have completed such a project: You think it is reusable and scalable, but later found in the use of the latest technology change, your system must be rewritten. Have you encountered this situation: You launched a project, but when you completed half, I realized that XML or the latest SOAP protocol used to improve the future system, and I found that this will destroy. Write each component and make the cost straight into the cloud. If you answer "Yes", you are not only those who meet this situation.

Under the current market competition conditions, companies need to make rapid and long-term decisions with minimal information. The wrong decision may affect each part of the company and make it backwards for a few months or even a few years. Enterprise administrative staff and technology developers want to know if there is a way to reduce development risks. This article describes a design pattern for building reusable enterprise components. ECC is a simple and intuitive design pattern, which has been developed, considering the same thing: changing. Business changes, rules change, technical changes, and personnel changes.

However, it is precisely because the changes in things don't mean you have to endure all the impacts brought about this change. From a business perspective, ECC design patterns help to reduce the impact of the following factors: the failure to meet - the meaning of the meaning and the meaning of understanding. Insufficient personnel - there may be inadequate personnel, but more manpower on a problem may also reduce the benefits. Higher learning requirements - In order to maintain and expand existing systems, only one programming language is not enough. More urgent time - the internet world is very fast, the door of the opportunity will be closed soon. Additional costs - Project overrun and program amendments caused by changes in projects will have an adverse effect.

From a technical point of view, ECC is a three-layer design pattern for developing N-layer business components that allow the creation, storage, and properties of components to be changed in a way that is minimal to the solution. ECC reduces changes in technology by using the following technique:

Component's standard and consistent interface, they increase ease of use. Heap-Oriented Oriented Object-Oriental Programming (OOP) / Object-Oriented Design (OOD), which is familiar to developers, such as design patterns and packages. Enable the components to be used only on the traditional "fat" client, you can also use simplified interfaces on the script client. Intuitive components creation methods make development easier.

The front-end plan using the scalable architecture is critical to the next generation of applications and services. Using ECC design patterns in current projects, you can develop a stronger and more flexible system that promotes future business development.

Development solution

Considering the following core elements when developing reusable design patterns:

N-layer distributed design (layered isolated) minimizes network calls (round trips) flexible architecture (adaptable) maintainability and scalability and simple and simple interface package package package package, centrally manage external dependence (independence of components Sexuality of real world entities and modeling of their interrelationships (Methods)

N-layer distributed design (layer isolation) application is divided into multiple layers to restrict the level of cascading effects that affect the application of another part of the application. Although this requires a longer front-end design time, the layered isolation reduces the operating cost compared to other alternative methods.

Minimize network calls Use web-based solutions (location transparency), the application's design must make the application to complete as much work in either end of the chain, while the amount of information sent online is at least. This concept can be extended to the reduction process, between the threads and the call between the context.

Flexible architecture lacks flexibility in applications from lack of flexibility. The most important question is: "What happens if there is a change?" The goal is to provide maximum scalability, reusability, maintainability, and independence (data sources, data location, language). In the final analysis, the purpose is to develop a design model, and this model will help reduce investment costs, scope of management, minimize the impact of various changes, and increase reusability while do not increase the use of complexity Sex and maintainability.

Maintainability and scalability and performance maintainability and scalability are usually at the expense of performance, but when the system enhancements are low, the performance of sacrifice will be compensated. If you must make a choice between maintainability and scalability and performance, maintain maintainability and scalability are always the best choice. The implementation of the design pattern will eventually have the ability to abandon an option to choose another.

Simple and consistent interface build simple inspiration mechanisms to call the objects in the system help to reduce the cost of training users and help reduce other developers' learning difficulties and knowledge requirements.

Package and centralize management of external dependent components can usually be inherited from external resources (such as operating systems). Most Windows components (or applications) provide security access depending on the operating system or other services (such as MTS or COM ). If this is unable to implement, or use inherited services to be lost, the external dependence in the centralized management component is valuable because it allows centralized control. Therefore, if these dependencies have changed, the programmer will not have to judge which modules or code segments need to be changed. The real world entities and their interrelated models (RDBMS, USE CASES, OOP) have many methods of methodology describing the real world and their process of interaction. Here are a few examples:

ERD, Flowchart and Database Design Use Cases (Model Entity and Its Solution) Object-Oriented Programming (OOP) Loosing the object to another object or the interface they implemented

The ECC design mode uses these methodology that has been proven to be proven to build a reusable design.

The ECC design model also constructs scalable, robust distributed systems in accordance with the Windows DNA model, and combines them with industry-standard design technologies such as OO design, design patterns, and database design. These technical knowledge is very common for those who deal with applications, so it is simply clear and reliable from a stage to the next stage.

This article refers to these core elements during the discussion of the ECC design mode. However, important point is to remember: this is not the final design pattern of each distributed application. It is just one of many choices, and you must consider implementation before adopting it.

ENGINE-Collection-Class Design Overview

Engine-Collection-Class design mode requires some different considerations with designers' habits. Designers tend to process a project with process design - what is the process I have to do with request or processing data? For ECC design patterns, these processes are second, and if the model is designed correctly, these processes will logically enter the object itself.

Figure 1 discloses the symbol relationship between Engine, Collection and Class. From a logical design point of view, Class is actually the main reason for Engine and Collection exists. Class links with the real world entity through its properties (such as names and surnames). Engine and Collection provide methods for managing and expanding its behavior. For entities to be modeled, all these three elements must be created.

Figure 1. ECC design pattern relationship diagram

ECC isolates the entity's creation, storage, and properties to provide a three-layer design for business objects.

The ECC design mode uses object-oriented technologies (such as packages) and some popular design patterns (such as Object Factory and Opaque Object Adapter).

Note: For additional information about these modes, read Visual Basic Design Patterns, which are listed in the reference.

Typically, Engine implements a design pattern called Object Factory, which defines an interface to create other objects. In this case, Engine creates both Collection objects and creates a Class object. Design Engine in this way provides the following benefits:

The security of the creation of a single interface control and mandatory object is provided and enforceable object creation by enforcing the creation of objects in the same COM unit, providing runtime benefits in multithreading process Provides loose coupling between clients and CLECTION and CLASS objects This can add new features without affecting the creation of the customer's known valid status.

Collection implements a mode called Opaque Object Adapter, which allows an object to package and use another object interface and functionality. This technique enables Visual Basic to simulate the inheritance of the implementation, even if it currently supports the inheritance of the interface. As shown in Figure 2, Collection contains a reference to ConcreteInternalStorage. This is called synthesis. The ConcreteInternalStorage object is used to store the Class object, and it can also be used to provide extended features for Collection based on the provided features. Array, Visual Basic's Collection object, Dictionary object, and ADO record set are examples of ConcreteInternalStorage objects. This makes Collection provide the following benefits:

Realized inheritance, although Visual Basic does not currently supports loose coupling between the CONCRETEINTERNALSTORAGE object enhancement function client and Collection's internal storage objects, allowing object changes to the client to produce minimal impact, or there is no impact on handling Class objects. Ability (such as calculation summor, count)

The Class implementation of the package means that the internal implementation details are hidden to the client using it. This provides the following benefits: Changing the implementation details do not affect the client.

Figure 2 discloses the object in the ECC design mode is a specific class. This means that there is no use of Visual Basic's IMPLEMENTS keyword, nor does there be an abstract class (only the interface that does not implement). Its main reason is that the ECC design model has been adjusted, and it is now using the same components to support traditional "fat" clients and forever-popular script clients without additional coding. This design decision helps shorten the time to market for projects and reduce costs, as you do not have to create or maintain different components for internal (or external) applications.

Figure 2. Engine-Collection-Class Model

The engine-collection-class model is implemented with the Object Factory design mode and the Opaque Object Adapter mode. This figure shows the basic method of each object.

Benefits

ECC design model is similar to the three-layer design of business objects, providing huge flexibility and benefits in business objects, such as calling interception, enforcing business rules, data verification, export properties, Simplified interfaces and mandatory objects are created.

A effective ECC design is pushed by a database (data source), and the latter is in turn driven by business needs. Typically, the data source scheme simulates the relationship and storage of entities in the real world, and puts a lot of effort in the development of data source or ERD. For ECC design modes, in order to be used as a starting point of the inherited basic business rules, the class maps to the database, the view, stored procedures, or other structured storage. Use this strategy to balance existing work and knowledge and easily explain the design of the system to others. This improves communication and feedback and reduces the problem of knowledge transfer. Object-oriented techniques (such as USE CASE) can be well obtained, such as Microsoft Visual Modeler, and tools such as Microsoft Visual Modeler and Microsoft Visio® can be used to explain and generate objects.

When modified or enhanced, the ECC can be extended by a new feature or method. This can be implemented by properly establishing a version of the interface published in COM.

Note: You cannot change, modify, or delete existing public interfaces without destroying COM compatibility. ECC does not resolve problems related to modifying systems; however, it helps make changes easier.

A consistent abstraction layer is provided with the Class package data source program characteristics for access and processing data. However, Class is not limited to data source program characteristics. You can define the exported properties as allowing additional functions. These attributes can exist from physical sense to another database (such as a data source such as LDAP or Microsoft Active DirectoryTM Service), or may be customized (isnew, isdirty), or can also be a polymeric function (SUM, Count). Finally, this abstraction layer means that the details are hidden and can be free to change and provide a place for calling interception. Call interception refers to such a capability: access request, and handles any mediation methods required to adjust the callor or the called request. For example, when you call the New operator in the Visual Basic, Visual Basic will create it when you first reference this object. Developers do not need to do anything for this function; however, you can't enter this call to change it. Developers can capture the interception type at a higher level (feature call, method call, interface call, and event). This gives the developer's ability to respond requests. This is a key feature because ECC uses this call interception to enforce business rules. For example, a business rule may be: The length of the password field must be at least 4 characters, but not more than 10 characters. The Password feature is an inspection and enforcement of a hook that implements this business rule, which ultimately maintains data integrity of the base data store without network calls. Another benefit is that this rule is only in a single location - if this rule changes, this location provides better manageability. The last one of the ECC design mode (but not least least least in the least) is that it is possible to provide a simplified interface. Because the interface defines the work that the component can be completed, it is like a binding contract. Unlike all details in a large document, the ECC has less interfaces and specific functions to divide the functions into each object. Therefore, each object can support a function of unlike itself but the role of the object is consistent in the entire application. For example, although ENGINE and Collection execute functions in different ways to each other, they will support the same basic functions. Engine is used to create a Collection and Class objects, and Collect is used to store and manipulate the Class object. Therefore, the object separates the more simplified interfaces, rather than create a super object that supports both interfaces. In addition, this allows each object to encapsulate specific functions and functions and make each object alone without affecting another object. In this way, developers have achieved flexible application design without sacrificing the simplicity or consistency. In addition, familiar developers who are familiar with this model can start working from various places in the development process without a sharp decline in production efficiency due to dramatically increased learning.

Below is a detailed description of each object and their meaning in the ECC model environment.

Class design

Class is designed to provide Bluemat to business components in real-world entities, and it is also the main reason for Engine and Collection objects. Class's responsibility is:

Implementing business rules in attribute levels and maintaining data integrity hide the implementation details of the Class property to simulate complex relationships (optional)

If there is a Class in the model, there must be an Engine and a Collection object. In the case where the class does not exist, there will be no corresponding collection, but Engine can exist, which will be used as a service or utility object. Because the business rules are specific to the project, their forced implementation is implemented. Important, your design architecture should allow you to flexibly define business rules in a place, and forgetting them in multiple places. Class's responsibility is to force the following aspects:

Data Validity - Maintaining Data Integrity Data Format - Allows Custom Format Conditions, which may include security of data conversion data access - check the user's completeness to ensure that they can update this field or perform this operation (provide Role-based security)

Unlike Engine and Collection, the method and characteristics of Class are based on data architecture. Each Class can image entities in your application. The mapping of Class features to data characteristics is implemented. For example, you can use a single class to reference three physical tables / views, or you can use three separate CLASS. Each design requires the purpose of analyzing the object and determines which model is best suited. Some things that need to be considered when you implement design include: method boundaries, transaction boundaries, security, and data locations (SQL ServerTM, COMTI, etc.). Figure 3 shows an ERD implemented by a sample. In this example, each entity has a class: userinfo, account, bill. Further, if the structure of the entity is similar, a single class can be used to represent a plurality of entities. In this case, IOBPLOOKUP CLASS implements this feature for ActivityType, BillType, Status, and Usertype. These tables mainly store read-only information to be used to place the control or drop-down list. One benefit of combining these entities into a class collection is sharing. For example, if the IObPlookUp class implements a cache mechanism, other components can use its feature. This reduces the amount of code to develop, test and maintain.

Figure 3. Online Bill Database Chart

This sample implements some additional business-specific fields:

RecordTimeSTAMP is used to lock the DELETEFLAG to delete a record that is deleted, and the deletion is generated by the external process: manual or automatic CREATETIME stores the date / time of the creation record to make the datedateTime stores the date / time of the last update record. Review

The entity in this model is accessed by the stored procedure, each stored procedure corresponding to a function (read, insert, update, and delete). This sample implementation uses a single stored procedure for multiple functions, but for ECC, you can access multiple stored procedures to make changes to the data, which will be implemented in Collection. They generate entities based on macro templates in Erwin (see the macro template "Database / Onlinebills.er1" in the code example corresponding to this article). You can use standard SQL statements, but in order to get real flexibility, you can encourage the use of stored procedures. If you decide to use the SQL statement, you should build a general SELECT, INSERT, UPDATE, and DELETE statements. But please note that there are some restrictions using the SQL statement. E.g:

Insert may need multiple round trips, depending on the generation of the line identifier and the use of the locking mechanism. The update may take multiple round trips based on the usage of columns like UpdatedateTime and RecordTimeStamp. Figure 4 illustrates a sample class Class, as well as other features that ECC should be included. Visual Modeler is used to generate an initial graphic obtained from a database table. Note that the object has a prefix C representing the Class.

Figure 4. Basic class of UserInfo entity

Each attribute in the database has two features: let () or set () and get (). Each feature is marked as public, protected (friends) or private. Figure 4 shows that the userNumber feature is shared readable (GET) and has a write (LET) protection. The userNumber feature is the primary keyword of the Class, so it should not be updated by an external entity because it is automatically generated from a database (such as an Identity column). By using this technique, Engine can initialize the characteristics of the Class, but still provide a mechanism to make the value cannot be tampered or changed. Class is self-contained because Class can be kept and recreated, so it is useful.

Basic recommendations for the Class interface are as follows:

Dirty-Boolean, Friend Let (), Public Get () - Settings when the property is changed at the record level. The Collection method also uses it to detect whether the status of the Class has changed. It cannot be used for read-only class. ClassStorage-Boolean, Friend Let (), Friend Get () - Used to bypass the internal business rules included in the attribute level. Engine also uses it to initially set a single feature, or Collection uses it to retrieve the value in Update (). Isnew-Boolean, Friend Let (), PUBLIC GET () - Settings when adding a new Class to Collection. Collection uses it to determine if there is no record in the data store. If you are not allowed to insert, it will not use it. This is similar to EditMode in ADO. SecurityToken-GUID (or a unique identifier), Friend Let (), Friend Get () - is used to limit the security symbol of the user for the field level. This feature is optional if field-level verification is required. Note: This is an ECC advanced concept that is not involved in this article but includes ECC in the implementation.

Other interfaces that can be added to this Class include:

Features of each field item with the corresponding LET (), Get () or set () method, as well as a statement (PUBLIC, Protected / Friend, Private). The export attribute or export method of the attribute return value is based on the attribute of the class. For example, if Class is Student, you can write a method to calculate average level. ON-Demand Loading features or methods used to load additional information during need. Usually retrieving this information is expensive in terms of resources and time, so you just want to get it when you need it. Hierarchy features, used to create hierarchies or structures in the design. For example, there is a pair of relationships between the UserInfo Class and the Account Class. A method can be added to access the Account information directly through the userInfo class. This method can be used with the on-demand loading characteristics. Note: This is an ECC advanced concept that is not involved in this article but includes ECC in the implementation.

In this case, in order to obtain flexibility, each common interface characteristic is defined using the Variant data type. Although these features can be set to other inherent data types, Variant provides the ability to deliver the project by reference to the script client. In the Visual Basic client, the Variant data type can be converted to a specific data type, which will eliminate performance issues. The only problem that still exists is: the fuzzy type of a parameter such as Variant can be anything. Use the document to describe these interfaces and publish this information to other developers to overcome this issue. Another benefit is that you can change the data type without redefining the interface. This allows the interface to better adapt to changes in business needs. The values ​​for each feature are stored in a private variable. They can be converted to the corresponding data type to enforce the type check of these values. This allows the corresponding error to notify the user that the invalid data type is used. It also encourages the value to be stored in a private variable according to their true storage. This may cause problems when the database can store NULL and data types (such as Integer). In order to solve this problem, this sample is implemented to use VARIANT for most private variables to process valid data values, and also processes NULL conditions.

Repeat this process for each entity that needs to be created for this application.

Class implementation

The GET feature is responsible for returning data to the caller, which may use the applicable special formatting conditions. A typical GET statement is as follows:

Public property Get Userid () AS VARIANT

ON Error Goto Errorhandler

IF me.classstorage thein

'Used to get raw data (unformatted)

Userid = mvaruserid

Else

'There is no special format of any special format

Userid = mvaruserid

END IF

<...>

End Property

The above IFEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEELSE The basic rules are as follows:

Check to determine if you should bypass the business rule (ClassStorage) check security or other Class level rules (not implemented in this example) to format or prepare data for customers.

You may have noticed that the IF..EELSE statement calculates the same condition because the code structure of the GET feature is pre-arranged; if this situation occurs, it can be easily implemented. This feature structure is very intuitive for code generating programs such as Visio and Visual Modeler. Providing templates for these tools will significantly increase production efficiency and reduce time limit on the project.

The LET feature is responsible for checking the data type, enforces business rules, and sets local (private) variables to incoming values. Each feature has a associated local variable, which is the same as the name of the characteristics, with a letter M (for member variables) and a type (Hungarian representation) before the name. The local copy of the ID feature will be: mvaruserid. A typical Let characteristic is as follows:

Public Property Let Userid (Byval VData As Variant)

Dim Errnum as long

Dim Errsrc as string

ON Error Goto Errorhandler

IF me.classstorage thein

'Used to change raw data (unformatted)

mvaruserid = VDATA

Elseif Me.Deleteflag Then

Err.raise Err_USERINFODELETEFLAGSET, "CUSERINFO.USERID Let", _ "Can't change the value Because the record is marked" & _

For deletion. "

Goto Cleanexit 'Note, this Provides A Safety Net

Else

'Disable error handling capture type does not match

ON Error ResMe next

mvaruserid = VDATA

IF Err.Number <> 0 THEN

'Use basic error plus application logo

Errnum = err.Number or obpexbusinessrule or obpusererror

Errsrc = Err.Source

Err.Clear 'reset the error stat

ON Error Goto Errorhandler

Err.raise Errnum, Errsrc, "Please Enter a Valid Value"

Else

ON Error Goto Errorhandler

END IF

'Check business conditions here

Me.dirty = true

END IF

<...>

End Property

The first IFSE line above, or a certain form of change should appear in each Let feature to ensure that the received data is a valid data type, and ensure that the caller is indeed incoming A value. The basic rules are as follows:

Check to determine if the business rule check should be bypassed (ClassStorage). Check security and other Class grade rules (such as delete conditions). Check if necessary to determine if this variable is not initialized. Check the data type. Check business rules (such as length). Format or prepare data for internal values ​​(not described in this example). Set dirty conditions (no read only).

The first step is to determine if the business rules should be bypass. Note that after the Class is completely placed, its ClassStorage feature is turned off. In this way, subsequent calls for this Class will check and enforce business rules. This reduces the overhead of loading Collection and Class, and allows access to raw data.

After enforcing the business rules, the next step is to check whether this Class is deleted. If so, update this feature is meaningless. This example will issue an error when this condition is encountered.

The final step is to force business rules. You can add an inspection to force the length of the userID to be more than n characters (actually, the minimum length value should be read from the system parameter table). If the data passes these tests, it assumes this value to a local copy.

In this example, another characteristic variable called Dirty is also provided. Dirty indicates whether the data has been changed. Note that there is no use of the member variable mvardirty to set this value directly; it is set to set it with a Let method of the dirty property. This ensures that these business rules will be enforced even if this feature is set inside the Class.

Note: Setting variables through the Let method exists some overhead, so in some cases directly using private variables are an acceptable approach. But be careful, this will make the assembly debugging and maintenance more difficult.

In the example above, a mistake called Goto CleaneXIT is issued. It never be executed, but should be used to explain the program process.

UserInfo Class also includes a method called Account. This shows that the ECC design mode is implemented on "On-Demand Load" (capable of loading the object when needed) and the ability to connect the different ECC components together. Because UserInfo and Account entities have a relationship (one-to-much), this implementation allows developers to retrieve an Account object in accordance with existing UserInfo objects. Therefore, it allows simple and intuitive code as follows: set objcaccount = objuserinfo.account.Item (1)

In the example below, the Account method returns a collection (COLACCOUNT) that contains Account Class (caccount). Used in the development cycle provides greater flexibility in the development cycle. You can avoid post-wocked by generating a TLB file for the component. Account objects, which are caccount and colaccount, reside in different DLLs in the UserInfo object, and are marked as publicnotable, so you must call Accent Engine to create and retrieve these objects:

Public property Get Account () As Object

ON Error Goto Errorhandler

DIM ENGACCOUNT AS Object

Dim Errornum as long

IF mcolaccount is nothing then

IF not SafeCreateObject (Engaccount, OBP_ACCOUNT_ENG, _

Errornum) THEN

Err.raise Err_accountsafecreatefailed, _

"Iobpuserinfoeng.account Property", "Unable to" & _

"CREATE" & OBP_ACCOUNT_ENG & ". Return Code:" & _

ErrorNum

Goto cleanexit

END IF

'Get only unselected records (default conditions).

Set mcolaccount = engaccount.search (securityToken: = _

SecurityToken, UserNumber: = me.usernumber

END IF

Set account = mcolacount

<...>

End Property

Take a closer look: First, check the internal variables to see if there is a reference to accomnt Collection. If so, returns this collection; otherwise, the Search method of the Account Engine is called to return one or more Account associated with the current usernumber. This means that each CUSERINFO CLASS in ColuserInfo Collection will have a specific Account or multiple Account - a single userNumber; in other words, a hierarchy. In addition, the Account Collection does not exist in the CUSERINFO before calling the Account method, thus being loaded as needed. Because the internal call to the Search method is only completed, the parameters like Refresh can be added to the interface of the object. This allows dynamic reloading content without destroying and recreating CUSERINFO. This shows the value of the loosely coupled objects constructed in the reusability of the ECC and the hierarchical structure. It also allows you to change the details of the implementation with minimal impact. Users will never know everything that happens under this cover. The code line of a sample user is as follows: straccountnumber = coluserinfo.item (1) .account.Item (1) .Number

Accurately understand the situation that happens in this line is important. First, assume that you have created a UserInfo Collection called ColuserInfo, where at least one account is at least one account. The first step, ColuserInfo.item (1) calls the ITEM method and returns the CUSERINFO Class corresponding to the user. Next, .account, create an Account Engine, this Engine creates an Account Collection and places it into one or more caccount coplas, and then returns this collection. Next, .Item (1), call the Item method for Account Collection, this method returns the first caccount class. The last step, .number, call the Number Property GET method and return a string with this account number, which is assigned to the StraccountNumber variable.

Getting a feature requires a lot of work, accessing each feature of the particular object means creating a Collection and Class for each property accessed. In this case, write this code as the following form:

Dim colaccounts as colaccount

Set colaccounts = Userinfo.item (1) .account

StraccountCode = Colacounts.Item (1) .Number

Strphone = colaccounts.Item (1) .custphone

Strname = colaccounts.Item (1) .custname

Using this method, the overhead of several calls to the Account method of UserInfo is avoided. It is also possible to use a for ...each structure. When you only access an account, you can write the following code:

DIM Objaccount as caccount

Set objaccount = userinfo.item (1) .account.Item (1)

StraccountCode = Objaccount.Number

Strphone = objaccount.phone

Strname = objaccount.custName This is very effective and reduces the overhead of calling the items () method multiple times for each account attribute. It should also provide optimal performance.

Collection design

Collection is the container of the Class object and is also packaged in the internal storage scheme. Most object-oriented developers, especially Visual Basic developers, should be familiar with the Collection / Class model. In the ECC model, the main responsibility of Collection is:

Provides a container that stores CLASS to separate the interface and container to the Class Provide Service Other Other objects to simulate complex relationships or hierarchies (optional)

You can use many different ways to implement the internal storage of Collection: array, link list, record set, XML, or another public data storage model. Here, the important concept is that actual storage is hidden in advanced developers, they always access data in the same way, regardless of its storage form. Like Class, the interface and implementation of Collection are also separated, which reduces the impact of changes in changes.

Here are other characteristics / methods for the sample Collection of CUSERINFO Class and ECC Design Mode. Visual Modeler is used to generate an initial graphic.

Note: The prefix COL of the object represents a collection.

Each Class has a separate Collection so that greater flexibility because it allows the Class to properly customize the interface. One of these examples is Add (), which requires the passing of specific UserInfo parameters.

Figure 5. Basic Collection Map of UserInfo Entity

For the basic recommendations of the Collection interface, the Collection interface provides creation, reading, updating, and deleting (crud) features as follows:

Add-long, public function () - is used to add a new Class to Collection according to the defined parameters. For example, this implementation requires new UserInfo Class to have four parameters before creating a new Class. It returns the index of the new object. Note: add () method should place the new class in the tail of the Collection, otherwise the existing index will be invalid. It can also check if this item has existing in advance (implemented). Count-long, public get () - Used to return the number of CLASS in Collection. DELETE-BOOLEAN, PUBLIC FUNCTION () - Used to delete one or more persistent Class from an external data source. Item - Class Object, Public Get () is used to retrieve items in Collection in accordance with the index offset. This may be expanded to support other index types or values. Load-Boolean, Friend Function () - Engine uses it to load the initial state of Collection and Class. This is very similar to the constructor of the object. This method should be protected to avoid security issues and data integrity issues. Remove-Boolean, public function () - Used to remove a class from the Collection according to the index keyword (in memory only). SecurityToken-Variant, Friend Let (), Friend Get () - Used to store user security symbols. This needs to be protected for security. Update-Boolean, Public Function () - Used to persist one or more Class to perseve it into the data source. This function can be inserted and updatable, depending on the value of Dirty and IsNew. Below is some other realized features / methods:

CLEAR-PUBLIC SUB () - Delete items in Collection (in memory only). This is good for memory management and special features (such as undo). Markfordelete-Boolean, Public Function () - is used to delete the tag for the project (deleteflag). This will not be transferred on the network before calling the Update method. This method is convenient when multiple items in Collection are needed. Newenum-iunkNown, Public Function (), Iterator - One method used in Collection. This method can be used in the Visual Basic's for .... This is an example of the usage of internal storage object functions. Note: This function requires support for internal storage, otherwise additional custom code is required. Store-Byte Array, Public Function () - Returns the internal storage of Collection in the form of a data stream. Note: This is an ECC advanced concept that is not involved in this article but includes ECC in the implementation. Undelete-Boolean, Public Function () - Cancel a project's delete tag (relative to MarkforDelete).

Most of this module is self-contained, but the delete and Update methods actually call the data access layer. Some of the key features of them include:

Pack Class information into a conveying structure (Variant (), recordset). Determine which command you need (stored procedure, interface, insert, update, delete). Send Class information to an external source (data access layer, ADO, COMTI). Expand the results into the internal memory. Other features added to Collection include:

Returns the export characteristics or methods of various values ​​depending on the Class in Collection. For example, if the Collection is a Student Class, a method can be written to calculate the average score of the Collection in the Collection. ON-Demand Loading features or methods used to load additional information during need. Typically, retrieving this information is expensive in terms of resources and time, so you just want to get it when you need it.

Repeat this process for each Collection that needs to be created for this application.

COLLECTION implementation

In most implementations, Collection is a package for the Collection of Visual Basic, and the Collection of Visual Basic resides in the private part of Collection. In most cases, Collection will contain the following methods: item (), count (), loading (), add (), delete (), and Update ().

Below is a discussion of each method.

Item ():

Public property Get Item (Byval Index As Variant) AS CUSERINFO

ON Error Goto Errorhandler

DIM MINTCODEID AS INTEGER

Set item = Nothing

IF mcol is nothing then

Goto cleanexit

END IF

IF mcol.count = 0 THEN

Goto cleanexit

END IF

IF Trim (Index & ") =" "" "or index <= 0 THEN

Goto cleanexit

Else

'Convert index into an integer, otherwise Collection will not work

MintCodeId = CINT (Index)

Set item = mcol.Item (MintCodeID)

END IF

<...>

End Property

Item () returns a CUSERINFO stored in Collection. It first checks: empty, range, and type, then set a reference for the Class.

This function may vary depending on the internal storage model used. For most of this sample, although using Visual Basic's Collection, the sample code does contain another sample of another storage model.

Note: This is an ECC advanced concept that is not involved in this article but includes ECC in the implementation.

Count ():

Public property get count () AS VARIANT

ON Error Goto Errorhandler

IF mcol is nothing then

COUNT = 0

Else

Count = mcol.count

END IF

<...>

End Property

Count () Returns zero or stores the number of CLASs in the interior.

Note: If you use the "Variable Group" for internal storage mechanism, you can determine the number of items like Ubound.

Load ():

Friend Function Load (Byval SecurityToken As Variant, Byval _filledStorage As Variant) AS VARIANT

ON Error Goto Errorhandler

LOAD = FALSE

mvarsecurityToken = SecurityToken

SET MCOL = FilledStorage

Load = True

<...>

END FUNCTION

The LOAD () method assumes that Engine has already filled the necessary data in the internal storage. It then only assigns data to a local variable. Allowing the ENGINE to fill the internal storage provides greater flexibility because it knows the original request. It also stores a copy of SecurityToken for use in the future, you need to use the request for processing.

Add ():

Public Function Add (Byval Userid As Variant, Byval UsertypeID AS _

Variant, Byval Password As Variant, Byval Name As Variant_

As Variant

ON Error Goto Errorhandler

Dim NewTemp as CuserInfo

'Set the default return value

Add = -1

'Check the parameter value

IF userid = "" or usepeid = "" or password = "" _

OR name = "" THEN

Err.raise Err_UserInfofailedaddcheck, _

"ColuserInfo.add Proc", "You Must Specify Values"

Goto cleanexit

END IF

IF mcol is nothing then

Set mcol = new color

END IF

Set newTemp = New CUSERINFO

WITH NewTemp

'Setting the field you want

.Classstorage = true

.Usernumber = 0

.Urserid = userid

. Usrtypeid = usepepeId

.Name = name

<...>

.Password = password

.SecurityToken = SecurityToken

.Classstorage = false

End with

'Add the item to the tail of Collection

IF mcol.count <> 0 THEN

Mcol.add newTemp,, McOL.COUNT

Else

Mcol.Add newTemp

END IF

Add = mcol.count

<...>

END FUNCTION

The add () method first checks if the transferred parameters meet the business rules. A user class (cuse) then assigns the default value to the feature and adds the CUSER to the internal storage. This method simultaneously creates a member of the internal Collection if there is no internal Collection that has not been created. This function returns the item number of the Class in this Collection so that the caller can access this item immediately.

Delete ():

Note: Remember that this method accesses an external source via the network.

Public Function Delete (Optional Byval Index As Variant) AS Varianton Error Goto Errorhandler

Dim Errornum as long

Dim Odaleng As Iobpda.iobpConnection

Dim OcuserInfo As CuserInfo

DIM VPARAM () as variant

DIM LOWERLIMIT AS Long

DIM UPPERLIMIT AS Long

DIM Inx as long

DIM SPNAME AS STRING

DELETE = FALSE

If me.count = 0 Then 'Nothing to Update

Update = TRUE

Goto cleanexit

END IF

'If an index is provided, you only delete the recorded record.

IF not ismissing (index) THEN

IF INDEX <1 or Index> Me.count Then

Err.raise Err_UserInfoIndexOutofrange, _

"ColuserInfo.delete Proc", "INDEX OUT OF RANGE"

Goto cleanexit

Else

LowerLimit = Index

Upperlimit = index

END IF

Else

LowerLimit = 1

Upperlimit = me.count

END IF

IF not SafeCreateObject (Odaleng, OBP_DA_CONNECTION, ERRORNUM) THEN

Err.raise Err_UserInfosafeCreatefailed, _

"COLUSERINFO.DELETE PROC", "Unable to Create" & _

OBP_DA_CONNECTION & ". Return Code WAS:" & ErrorNum

Goto cleanexit

END IF

For Inx = LowerLimit to UpperLimit

Set obstoSerinfo = Me.Item (Inx)

IF not OcuserInfo.isnew then

'Delete from db if not new

Redim vParam (Parmubound, 1)

With opuserinfo

.Classstorage = true

'Fill Parameter Array

vParam (PARMNAME, 0) = PARMNAMESP_USERINFOUSERNUMBER

vParam (PARMTYPE, 0) = PARMTYPESP_USERINFOUSERNUMBER

VParam (PARMLENGTH, 0) = 4

vParam (Parmdir, 0) = adInput

vParam (ParmValue, 0) = .userNumber

<...>

.Classstorage = false

End with

If not odaled.execute (SecurityToken, sp_userinfo, _

vParam) THEN

Err.raise Err_UserInfodaldeletefailed, _

"Coluserinfo.delete Proc", _

"Delete failed. SPName WAS:" & sp_d_userinfogoto cleanexit

END IF

END IF

Set obstoSerinfo = Nothing

'Remove from Collection

Mcol.Remove (Inx)

NEXT

Delete = true

<...>

END FUNCTION

The delete () method deletes one or more items from the data store (usually the database). If this item is not a new (isnew = false), it will be removed from the database. This is because its IsNew features set to real projects do not exist in the database. This method completes the deletion by packaging the primary keyword and the recording timestamp; this information is passed to the data access object, the latter will delete this record. This item is then removed from the Collection to ensure that the client does not access data from not in the database. This is useful for the "fat" client that maintains a state.

Note: The delete method may cause the collection's ItemIndex to change, especially when it is stored in the user code. It is recommended to refresh the reference after Delete () to ensure that they point to the correct project in Collection.

Update ():

Note: Keep in mind that this method also wants to transfer on the network.

Public Function Update (Optional Byval Index As Variant) AS VARIANT

ON Error Goto Errorhandler

Dim Errornum as long

Dim Odaleng As Iobpda.iobpConnection

DIM RS As Ador.Recordset

Dim OcuserInfo As CuserInfo

DIM VPARAM () as variant

DIM LOWERLIMIT AS Long

DIM UPPERLIMIT AS Long

DIM Inx as long

DIM SPNAME AS STRING

Update = false

If me.count = 0 Then 'does not want to update items

Update = TRUE

Goto cleanexit

END IF

'If you provide an index, you only update the recorded records.

IF not ismissing (index) THEN

IF INDEX <1 or Index> Me.count Then

Err.raise Err_UserInfoIndexOutofrange, _

"ColuserInfo.update Proc", "INDEX OUT OF RANGE"

Goto cleanexit

Else

LowerLimit = Index

Upperlimit = index

END IF

Else

LowerLimit = 1

Upperlimit = me.count

END IF

IF not SafeCreateObject (Odaleng, OBP_DA_CONNECTION, ERRORNUM) THEN

Err.raise Err_UserInfosafeCreatefailed, _

"ColuserInfo.update Proc", "Unable to create" & _

OBP_DA_CONNECTION & ". Return Code WAS:" & ErrorNum

Goto cleanexit

END IF

For Inx = LowerLimit to UpperLimitSet Ocuserinfo = Me.Item (Inx)

IF obscuserinfo.dirty Then

Redim vParam (Parmubound, 16)

With opuserinfo

.Classstorage = true

'Filling parameter number

vParam (PARMNAME, 0) = PARMNAMESP_USERINFOUSERNUMBER

vParam (PARMTYPE, 0) = PARMTYPESP_USERINFOUSERNUMBER

vParam (PARMLENGTH, 0) = 0

vParam (Parmdir, 0) = adInput

vParam (ParmValue, 0) = .userNumber

<...>

.Classstorage = false

End with

'Check if an existing record is updated to the database

IF cSerinfo.isnew = false kil

'Update this record

SPNAME = SP_U_USERINFO

Else

'Insert this record

SPNAME = SP_I_USERINFO

END IF

IF not Odaleng.execute (SecurityToken, Spname, VParam, _

RS) THEN

Err.raise Err_UserInfodalupdatefailed, _

"ColuserInfo.update Proc", _

"Update to Database Failed. SPName WAS:" & _

SpName

Goto cleanexit

Elseif (Not Rs Is Nothing) THEN

'If no data is returned in DB, set to TRUE

IF r.recordcount> 1 THEN

Err.raise Err_ReturntoomanyRecords, _

"ColuserInfo.update Proc", _

"Update to Database Failed. Returned More" & _

Than One Record. SPName WAS: "& SPNAME

Goto cleanexit

Else

'Update Collection with Returned Data

With opuserinfo

.Classstorage =

.Usernumber = rs.fields (fn_userinfousernumber)

.Userid = rs.fields (fn_userinfouserid)

. Usrtypeid = rs.fields (fn_userinfousertypeid)

<...>

.New = false

.SecurityToken = SecurityToken

.Classstorage = false

.Dirty = false

End with

END IF

END IF

END IF 'DIRTY

Set obstoSerinfo = Nothing

Next Inx

Update = true

<...>

END FUNCTION

Update () is similar to delete () because it can update one or more items. Another key function is to make a choice between insertion and updates. Used again, in this case, True indicates that this method should be inserted, while false means it should perform updates. The information of the class is packaged, and then sent to the data access object and is inserted or updated there. Once remote updates or inserts, the internal Class is updated to reflect those changes that may have changed the database. For example, RecordTimeSTAMP will change or be created, so the Class needs to reflect this new value. For additional functions, see the code sample related to this article. ENGINE Design ENGINE is a layer on Collection and Class, which is a single entry of Class and Collection. Engine is an insulating layer that is controlled by security and object creation. Its key responsibility is as follows: Agent that acts as creating a Collection and Class check security before creating an object, packed multiple CLASs into a collection and returning them to the client to provide a standard interface for accessing Collection and Class to provide business specific processing ENGINE It is a common interface for special objects and is the only publicly created Class in the ECC model. This has a lot of benefits. As a unique object, Engine exists independently and implements general business functions. Because of this feature, Engine is called a service and there is no corresponding Collection and Class. An example of a service object is: only business processing and returns a value. IOBPSecurity implementation describes how the service object works. In the case where Engine is more powerful, it will be used in conjunction with Collection and Class. In this case, Engine is the main interface of other objects and can control their creation. As illustrated in Figure 2, Engine is associated with Collection and Class in a certain extent, as it must know how to retrieve Class information, package it, and place them into Collection. However, in terms of implementation details, ENGINE is just a loose coupling relationship between these objects. Several main reasons for this design ENGINE are:

Enforce security for object creation. No COLLECTION or CLASS cannot be created without Engine verification, any person (or process, or server, etc.). Verification can be done by external components, so it is possible to freely change the security of the application. Separate the interface of access objects with their implementation, so that the implementation of the Collection and Class can change without affecting the Customer (or multiple customers) that call this ENGINE. The interface also provides standard methods for calling these objects. Hide (or package) the creation of the object. ENGINE can perform COLLECTION and CLASS creation requests in a variety of different ways. In each scenario, users will not be affected, and developers have greater flexibility. One of the key roles of Engine is to provide a way to pack and return to Class. This feature is implemented in one or more methods with prefix Get. ENGINE does not return a single Class. It first puts each class into a collection and then returns this Collection. Therefore, to enable ENGINE to work in the ECC model, it must provide a method to return Class. A sample of CuSerinfo and Coluserinfo will be discussed below; then discussions should include other features / methods in the ECC design mode. Visual Modeler is used to generate an initial graphic. Note: ECC design mode uses a consistent object naming convention. At the ENGINE level, the object name is a combination of a prefix and suffix. The prefix is ​​divided into two parts: "i" means interface, "OBP" represents application-specific code or first letters. The suffix "ENG" means ENGINE. This naming convention has two functions: objects can be more easily found in the registry, and the object is combined in Visual Basic IDE References WINDOW. Figure 6: Basic engine diagram of the UserInfo entity In this example, the key approach is called GetUserInfo. The syntax is usually Get . This allows ENGINE to return one or more Collection and Class. Another way to achieve this is to use more specific methods, such as GetUsersbyemail. This method will return multiple users of a particular email address, which is very intuitive. The method selected in this sample implementation uses a more general Search method, which accepts several different optional parameters as the found basis and returns different users. Realize the details to be determined. You can add business-specific other functions to userinfo engine. For example, an EnrollUser function can be provided as a method of registered a user in the system. As mentioned above, this is where the process must be implemented into the ECC design. These process surfaces look at their position - with objects to show this feature. In addition, Engine is a stateless object; therefore, it should not be characteristic. Below is the basic method that should be provided in this implementation:

Get is responsible for creating a Class, popping information into these Class and puts them in a collection, and then returning to this Collection. At least there should be a method belonging to this type. This method is usually retrieved in its primary keyword. The default behavior of this method (or returning a collection) is the default behavior of this method (or returning a collection). Returns an empty collection is designed to enable customers to call col .add () instead of returning to Engine and calling the new () method. This processing method enables customers to check counts and then immediately call the add () method and the returned Collection. Another default behavior is an error condition; this will occur when some errors appear. When this happens, you should do two things: first set the return reference to empty, then send an error to the customer (caller). Other methods include: Search is very similar to get , but this method can be used on any field. It is best to define data parameters as optional to support growth. The code of the base layer will determine if the user has passed sufficient data to perform the corresponding search. NEW Create an empty collection for adding CLASS. This is good for data items that originally do not need to go to the data source. RESTORE is relative to the Store method on the Collection. It allows customers to restore (or recombine) the persistent status of Collection and Class. Note: This is an ECC advanced concept that is not involved in this article but includes ECC in the implementation. Other features that may be added to ENGINE include:

Service-based approach, getUsertype is an example of it. This will return Usertype according to userNumber. Engine's implementation Engine is responsible for creating a Collection and populates it with one or more Class. Because of this feature, Engine is called a factory because it is responsible for creating other objects. In ECC design mode, Engine is a very specific factory that can create specific Class. The following sample code shows how the customer will write code and how to return a UserInfo Collection (ColuserInfo) using Engine: DIM Usengine As Useng

DIM Uses as coluserinfo

DIM User as cuserinfo

DIM STRUSERNUMBER AS STRING

Set useerengine = new iobpuserinfoeng

Strusernumber = 10

Set users = usengine.getuserinfo ("token", strusernumber)

Set useerengine = Nothing

Set user = users.Item (users.count)

Msgbox User.Name & "'S E-mail address is:" & user.emailaddress

As you can see, the client application only needs to know the user number to access information about this user without having to understand the details of the underlying, as the field name of the requested data or how to process internal storage (such as record set or XML) DOM object). This change will only occur in Engine if the field name or internal storage changes, this change will only occur in Engine without happening in a client application that uses the class. Note that Engine returns a user's Collection, once completed this task, ending ENGINE and you can delete it (set to empty). The characteristics of these items can now be used in Collection. The implementation of the GetUserInfo method is as follows: Public Function GetUserInfo (Byval SecurityToken As Variant, _OPTIONAL BYVAL UserNumber As Variant, _

Optional byval deletedRecords as deleteRecordType = _

NondeletedRecords) As ColuserInfo

ON Error Goto Errorhandler

Dim Errornum as long

Dim Odaleng As Iobpda.iobpConnection

DIM RSUSERINFO As Ador.Recordset

DIM OCOLUSERINFO As Coluserinfo

Dim OcuserInfo As CuserInfo

Dim vParameters () as variant

DIM COL As Collection

DIM Inx as long

Set getUserinfo = Nothing

'First check the security symbol

IF Trim (SecurityToken) = "" "" "

Err.raise Err_UserInfoinValidSecurityToken, _

"Obpuserinfoeng.getuserinfo proc", _

"INVALID Security TOKEN. Security token Cannot Be EMPTY."

Goto cleanexit

END IF

Redim vParameters (Parmubound, 0)

IF ismissing (usernumber) THEN

Usernumber = null

Elseif Trim (UserNumber) = "" ""

Usernumber = null

END IF

'Packing parameters

VParameters (Parmname, 0) = PARMNAMESP_USERINFOUSERNUMBER 'Name

vParameters (ParmType, 0) = PARMTYPESP_USERINFOUSERNUMBER 'Type

vParameters (PARMLENGTH, 0) = 0 'size

vParameters (Parmdir, 0) = Adinput 'direction

vParameters (ParmValue, 0) = usernumber '

IF deletedRecords <> allrecords kil

IF not isemptyArray (vParameters) THEN

Inx = ubound (vParameters, 2) 1

Redim Preserve vParameters (Parmubound, Inx) Else

INX = 0

Redim vParameters (Parmubound, Inx)

END IF

VParameters (Parmname, Inx) = PARMNAMESP_USERINFODELETEFLAG

VParameters (ParmType, Inx) = PARMTYPESP_USERINFODELETEFLAG

VParameters (PARMLENGTH, INX) = 1 'size

VParameters (Parmdir, Inx) = adInput 'direction

vParameters (ParmValue, Inx) = deletedRecords'

END IF

'Creating a "Data Access Layer" object

IF not SafeCreateObject (Odaleng, OBP_DA_CONNECTION, ERRORNUM) THEN

Err.raise Err_UserInfosafeCreatefailed, _

"IOBPUSERINFOENG.GET PROC", "Unable to create" & _

OBP_DA_CONNECTION & ". Return Code WAS:" & ErrorNum

Goto cleanexit

END IF

'Execute SQL to retrieve record

IF not isemptyArray (vParameters) THEN

If not odaled.execute (SecurityToken, sp_s_userinfo, _

vParameters, RSUSERINFO) THEN

Err.raise Err_UserInfodalCallFailed, _

"Obpuserinfoeng.get proc", _

"Call to Database Failed. SPName WAS:" & sp_s_bill

Goto cleanexit

END IF

Else

If not odaled.execute (SecurityToken, sp_s_userinfo,, _

Rsuserinfo) THEN

Err.raise Err_UserInfodalCallFailed, _

"Obpuserinfoeng.get proc", _

"Call to Database Failed. SPName WAS:" & sp_s_bill

Goto cleanexit

END IF

END IF

Set Odaleng = Nothing

IF (Not RsuserInfo Is Nothing) THEN

'Start packing data into multiple Class objects

Set Ocoluserinfo = New Coluserinfo

Set col = New Collection

Do Until RsuserInfo.eof

Set obstoSerinfo = New CuserInfo

With opuserinfo

.Classstorage = true

.Usernumber = rsuserinfo.fields (fn_userinfousernumber)

.Userid = rsuserinfo.fields (fn_userinfouserid)

. Usrtypeid = rsuserinfo.fields (fn_userinfousertypeid)

<...>

.SecurityToken = securityToken.isnew = false

.Classstorage = false

.Dirty = false

End with

Col.Add Ocuserinfo

RSUSERINFO.MOVENEXT

Set obstoSerinfo = Nothing

Loop

'Place the information into the Collection object

IF not ocoluserinfo.load (securityToken, col) THEN

Err.raise Err_USERINFOLOADFAILED, _

"Obpuserinfoeng.getuserinfo proc", _

"Load Faled for Private Collection"

Goto cleanexit

END IF

'success

Set getUserinfo = OCOLUSERINFO

END IF

<...>

END FUNCTION

The GetUserInfo method is to explain the main examples of how the Get Engine method should be defined. Here are basic recommendations:

Check security, or ensure that the caller has permission to call this method, or force the role-based security. Pack the passing parameters or other desired fields. Call the data source (our implementation uses a "data access layer" object) to retrieve data. Unpack the data into multiple classes. Fill the Collection and return it to the caller.

Implementation When the business component is running in the same process space, the ECC model is the highest. Widely used object characteristics is the main reason. Each call to a feature requires a round trip from the customer to this object. If these round-trips cross the process boundary, the overhead becomes considerable. In a web-based solution, this means that these objects are running in the same process space in the same process space. In this case, it is best to configure the Web site to run in a separate memory space. This provides an error isolation function that allows the web server to restart this process after the process is aborted. The author of this article has used this method to achieve great success on multiple projects or customers. We found that the most powerful part of the ECC design model is the way it advocates. As a project host, we can teach the developers and quickly review the code that does not match it. Because it is a model that has been proven to this implementation, it allows us to use more time to examine customer specific requirements. In addition, most of the code is a shear and paste operation; once the first service component (template) is created, other components can be used as a starting point. Generally speaking, the object's debugging and design makes it more common in all components, making developers more easily exchange tasks. There will be multiple changes in the design phase of the project, which ranges from the UI to the database. We can implement many changes in the case where the system has a minimum impact. Below is a few examples of the changes made:

The initial design of the data transmission format will use the ADO recordset as a data transfer format. A design change requires an application to transfer data to XML. If you use the previous method to return the recordset to the ASP, we will have to modify each code in the application. ECC provides an isolation layer between the developer between data transfer and ASP code. This layer greatly reduces the impact because the number of Active Server Pages is more than ten times higher than the number of components. Safety initial design uses physical level security, with traditional CRUD functions. Safety is achieved at ENGINE and Collection. A design change requires design that requires column-level security privileges. Because ECC advocates the characteristics of mapping to columns, we will soon achieve this requirement. To do this, we must store SecurityToken in the class level (via the Engine or Collection method) and check the user's permissions when calling the corresponding feature method. Encrypted initial design Use the Store / Restore method for the persistence of components. Customer cares: Byte () is a readable format after storage to the database. Because we don't use the built-in IPERSIST method, encryption / decryption can be added to the corresponding method. Note: If Class is publicly created, you can only use ipersist in Visual Basic; without using Collection and Class methods. The initial design of the cache is encouraging many performance issues, especially for displaying a page multiple rounds between databases. There is a problem with a plurality of drop-down lists, each corresponding to a separate round trip, and each time you have multiple users to travel. In order to improve performance, we have added a cache in the corresponding components. We also modified ENGINE to check the cache first before the travers of the database. These are just a few examples of flexibility in the ECC design pattern.

转载请注明原文地址:https://www.9cbs.com/read-5257.html

New Post(0)