advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Partners & Affiliates
advertisement
advertisement
Average Rating: 2/5 | Rate this item | 6 users have rated this item.
 Print Print
 
Using the Domain Objects Persistence Pattern in .NET
Domain application objects are usually central to the entire application and used by most subsystems. They represent the core data and business validation rules; therefore, good domain object design is critical for robust, high performing, yet flexible applications. 

advertisement
hen developing object-oriented applications that use relational databases, creating a domain object design that's consistent with the database design makes applications easier to understand, because domain objects typically represent real-life "entities" and their relationships with each other. Therefore, in many situations, the 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 developers to have a solid understanding of object oriented and relational fundamentals.

The Domain Objects Persistence pattern attempts to provide a mapping to relational databases that decouples the domain objects from the persistence logic. In this pattern, the domain objects themselves are unaware of the persistence mechanism, because the dependency is only one-way (from persistence objects to domain objects). This simplifies the domain objects' design and makes them easier to understand. It also hides the persistence objects from other subsystems in the application that are using the domain objects. Even better, the pattern also works in distributed systems where only the domain objects are passed around, thus insulating the application from exposing the persistance mechanism to outside code. This article shows you how to incorporate the Factory pattern into the Domain Objects Persistence pattern to help decouple domain objects and persistence logic.

Defining the Problem
Domain objects form the backbone of any application. They capture the core data model from the database and the business rules that apply to that data. Typically, most subsystems of an application rely on these common domain objects—meaning that the more closely the domain objects map to the database schema, the easier it is for application developers to understand and use them because they mimic the real-life "entities" and "relationships" represented in the database.

When domain objects are not separated from the rest of the application, you often end up with duplicated persistence code in multiple locations. Similarly, when domain objects are not separated from the persistence code, you'll face situations where any subsystem using the domain objects must also know and depend on the persistence objects. Any change in persistence objects necessarily affects the entire application; hence, failing to separate domain objects from the application and the persistence code is a bad design.

Defining a Solution
One way to achieve the above-mentioned goals is to separate the domain objects into a separate subsystem and let the rest of the application use them whenever it needs domain data. Additionally, you should separate domain objects from the persistence code. On one hand, this double-decoupling avoids code duplication, and on the other it hides the persistence details from the domain objects, creating a flexible design that's easier to change. The domain objects and the rest of the application are totally unaffected whether the data comes from a relational database, an XML file, a flat file, Active Directory/LDAP, or any other source.

In separating persistence logic from domain objects, you must ensure that the domain objects have no dependency on the persistence code. Doing that allows you to expose the domain objects even in environments where you don't want to expose the persistence code.
Page 1 of 2
advertisement
  Next Page: Building an Example
Page 1: IntroductionPage 2: Building an Example
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES