steps to writing a research paper , steps write essay, steps write paragraph, steps thesis writing
Sunday, October 25, 2009
Domain Objects Persistence Pattern for NET
Domain Objects Persistence Patte for NET Abstract objects in a domain application represent the core of data and validation rules that affect them. And, the domain objects are usually central to the application and used by most subsystems. Therefore, their good design is essential for the proper application of design that is robust, high performance, yet flexible. When it comes to developing object-oriented applications that use relational databases, the domain object design should be compatible with the design of databases. This makes it easier to understand because they represent real-life "entities" and their relations with each other. Therefore, in many cases, domain objects are "mapped" to the relational database tables and relationships between tables. However, it is very easy to get this mapping wrong and end up with an undesirable domain object design. A good design for domain objects requires a solid understanding of relational and object-oriented core developers. Domain Objects Persistence Patte tries to provide a solution for domain object mapping to relational databases that decouples the domain objects persistence logic. The field of this configuration, the objects are not objects that persist because of the dependence is only one way (from persistence objects to domain objects). This makes the design of domain objects much simpler and easier to understand. It also hides the persistence objects from other subsystems in the application that uses the domain objects. And it works well in distributed systems, where only the domain objects are passed around. In this context, it attempts to integrate the system into this plan in order to help decouple domain objects persistence logic. Extension of the area of objects, the persistence of domain objects. Definition of problem domain objects which form the backbone of any application. Model captures the basic data of the database and the rules that apply to that data. It 'very typical for most subsystems of an application to build on these common domain objects. This means that over the range of items in the map data model in the database, which is easier for developers to understand and use it to simulate the real-life "entities" and "reports" represented in the database . If domain objects are not separated from the rest of the application, you end up with duplication of code everywhere. Similarly, if the domain objects are not separated from the persistence code, we are faced with situations where any subsystem using the domain objects also knows and depends on the persistence of objects. And any changes in the persistence of objects in any application, where a bad design. Solution One way to achieve the above objectives is to separate the domain objects in a sub-system and let all that the use of the domain in which you need data. Furthermore, it should be separate items in the persistence code. This allows you to double the decoupling on the one hand, to avoid duplication of code and another to hide the persistence of domain objects and make it more flexible, in case it needs to change. The domain objects and the rest of the application is totally unaffected whether the data from a relational database or another source (eg XML, flat files, or Active Directory / LDAP). In separating the persistence logic from domain objects, it ensures that the domain objects have no dependency on the persistence code. This allows you to become a domain of items available in environments where you do not even want to expose our persistence code. Examples of code in this example is viewed from an object database of clients associated with the "customers" table in the database. public class Client (/ / data members private String _customerId; _companyName String; _contactName String, String _contactTitle; public Client () () / / Properties public String client object client (_customerId get (retu;) set (_customerId = value; )) public String (CompanyName _companyName get (retu;) set (_companyName = value;)) public String (ContactName _contactName get (retu;) set (_contactName = value;)) public string ContactTitle (_contactTitle obtain (round and back;) set (_contactTitle = value;))) public interface ICustomerFactory (/ / Standard transactional methods for single line operations zero load (Customer Cust); void Insert (Customer Cust) void Update (Customer Cust); void Delete (Customer Cust) / / Query method to retu a collection ArrayList FindCustomersByState (String state)) public class CustomerFactory: ICustomerFactory (/ / Standard transactional methods for single line operations zero load (Customer Cust) (/ * Implement here * /) void Insert (Customer Cust) (/ * Implement here * /) void Update (Customer Cust) (/ * Implement here * /) void Delete (Customer Cust) (/ * Implement here * /) / / query to retu a collection method FindCustomersByState ArrayList (String state) (/ * Implement here * /)) Here is an example of how a client that uses this code. public class NorthwindApp (static void Main (string [] args) (Customer Cust = new Customer (); CustomerFactory custFactory = new CustomerFactory () / / Let's load a customer from the Northwind database. cust.CustomerId = "ALFKI"; custFactory. load (Cust); / / Pass on the client object foobar (Cust); / / CustList is a collection of objects custList customers ArrayList = custFactory.FindCustomersByState ( "CA"))) As you can see above, the "cargo" method loads the Customer object database based on the client. Once the client is loaded, it can be sent to each subsystem for the application without exposing the persistence code. Similarly, if you get an ArrayList of Customer objects, you can pass on the ArrayList which has no persistence code dependency. Conclusions The use of the model of persistence of domain objects, we extracted the persistence code to the client object. This customer has been the subject of several object-oriented and easy to understand because its object model is closer to the model data in the database. And finally, we have allowed the subject of the customer to move different parts of the application (or even through the applications. NET Remoting) without exposing the persistence code. Author: M. Iqbal Khan works for AlachiSoft, a leading provider of software for O / R Mapping solutions for clustering and caching of objects. NET. You can reach him iqbal@alachisoft.com or visit Alachisoft Copyright Iqbal Khan --
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment