65873 members! Sign up to stay informed.

Sponsored Links


Resources

.NET Research Library
Get .NET related white papers, case studies and webcasts

News News News Messages: 20 Messages: 20 Messages: 20 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

Domain Objects Persistence Pattern for .NET

Posted by: Nuno Teixeira on August 04, 2005 DIGG
Iqbal M. Khan describes a pattern in which persistence logic is abstracted away from Domain Objects, including C# source code for an implementation of the pattern.
If domain objects are not separated from the rest of the application, we end up with duplication of code everywhere. Similarly, if domain objects are not separated from the persistence code, we face situations where any subsystem using the domain objects also knows and depends on the persistence objects. And, any change in persistence objects affects the entire application, hence a bad design.
Read Domain Objects Persistence Pattern for .NET

Threaded replies

·  Domain Objects Persistence Pattern for .NET by Nuno Teixeira on Thu Aug 04 11:14:46 EDT 2005
  ·  Isn't this pattern called layering? by Mike Two on Thu Aug 04 14:21:45 EDT 2005
    ·  DataMapper by Grant Carpenter on Thu Aug 04 15:22:27 EDT 2005
      ·  DataMapper by Paul Ballard on Thu Aug 04 15:35:32 EDT 2005
        ·  DataMapper by Grant Carpenter on Thu Aug 04 19:18:40 EDT 2005
      ·  Other sources by Scott Rudy on Wed Aug 10 06:54:10 EDT 2005
    ·  gateway pattern in fowler's book by are ski on Thu Aug 11 11:17:31 EDT 2005
    ·  DAO and Business Logic by Humberto Ma on Fri Apr 21 00:23:46 EDT 2006
  ·  Domain Objects Persistence Pattern for .NET by Edwin King on Fri Aug 05 10:00:44 EDT 2005
    ·  Grog Object Model by Joshua Smith on Fri Aug 05 10:14:53 EDT 2005
      ·  Teh Winnah by Sean Malloy on Tue Aug 09 17:45:30 EDT 2005
  ·  I call it the Java DAO Pattern by Sean Malloy on Tue Aug 09 17:46:38 EDT 2005
  ·  Domain Objects Persistence Pattern for .NET Article Quality by Sandu Buraga on Wed Aug 10 02:44:39 EDT 2005
  ·  Not so bad by Simone Chiaretta on Wed Aug 10 03:54:51 EDT 2005
  ·  Repositories by Morten Mertner on Wed Aug 10 05:00:16 EDT 2005
  ·  Don't bother mapping, go for an open source OODBMS for .NET by Thomas Jaeger on Wed Aug 10 10:32:25 EDT 2005
  ·  Such a Pity... by Rajesh Ramesh on Thu Aug 11 14:15:11 EDT 2005
  ·  Factory vs. Mapping Objets by Jean-Daniel Gamache on Wed Aug 17 13:10:12 EDT 2005
  ·  Pointless?? by Jan Bannister on Fri Aug 26 06:50:39 EDT 2005
  ·  Factory pattern by Patrik Löwendahl on Sun Aug 28 17:10:04 EDT 2005
  ·  How is it different than DAO pattern? by Ruslan Zenin on Tue Sep 13 10:12:03 EDT 2005
  Message #180333 Post reply Post reply Post reply Go to top Go to top Go to top

Isn't this pattern called layering?

Posted by: Mike Two on August 04, 2005 in response to Message #180301
Or at least it is Fowler's Domain Model pattern.

  Message #180341 Post reply Post reply Post reply Go to top Go to top Go to top

DataMapper

Posted by: Grant Carpenter on August 04, 2005 in response to Message #180333
He's basically coming up with his own version of what Fowler et al have already documented. I'd call it Mapper/Data Mapper if anything (Gateway if we want to be blithely academic and pretend the domain objects don't have some implicity linkage to the backing store).

Since a major premise of patterns is a common vernacular, the author would do better to use well-known prior works and refer to his explanation as such.

http://www.martinfowler.com/eaaCatalog/mapper.html
http://www.martinfowler.com/eaaCatalog/dataMapper.html
http://www.martinfowler.com/eaaCatalog/domainModel.html

  Message #180348 Post reply Post reply Post reply Go to top Go to top Go to top

DataMapper

Posted by: Paul Ballard on August 04, 2005 in response to Message #180341
I don't believe that the author was attempting an original piece with this as much as a description of what others are doing. Patterns are by definition based on what has already been done.

The question I would ask is how useful is this pattern, or this implementation, compared to others?

  Message #180373 Post reply Post reply Post reply Go to top Go to top Go to top

DataMapper

Posted by: Grant Carpenter on August 04, 2005 in response to Message #180348
My exception isn't really that he's claiming he invented this construct--it's more that he should use pre-existing name for this pattern rather than invent a new one.

The only place this pattern is called the "Domain Objects Persistence Pattern" seems to be in the various copies of this article that have been published.

http://tinyurl.com/9asjx
http://tinyurl.com/bsos7
http://tinyurl.com/e2nyq
http://tinyurl.com/7kawt
http://tinyurl.com/dj9eb

On the other hand, the Data Mapper pattern is a pre-existing name given to this specific idiom. One of the main benefits of design patterns is creating a common vocabulary that architects and developers can use to have more fluid discussions.

If you say a Singleton, I know exactly what you mean. If you call it a Singularly Constrained Instance Existence Pattern, all I'm going to do is wonder if you mean a Singleton. So in addition to the benefit of using proven idioms that have stood the test of time, being able to have a common set of semantics regarding these idioms is another significant benefit of patterns.

Is Data Mapper useful? Sure it is. Data Mapper vs. ActiveRecord (http://tinyurl.com/b9z2q) tends to be the typical design tradeoff between convenience and loose coupling. Most of the common persistence frameworks structure theire api or generated code in one of these two data access primitives.

A compare/contrast of the mainstream ORM/persistence frameworks would probably make for an interesting read, either that or a more concrete illustration of the subject pattern so that people learning from the article can go from concept to working example in a sitting.

  Message #180459 Post reply Post reply Post reply Go to top Go to top Go to top

Domain Objects Persistence Pattern for .NET

Posted by: Edwin King on August 05, 2005 in response to Message #180301
uhhh...an the point is?

There's a few sections missing from the pattern description that would be nice to see (not that you always need them all) like Consequences, AKA, Known Uses, Related Patterns, etc.

...and I see nothing new here besides the name...

  Message #180461 Post reply Post reply Post reply Go to top Go to top Go to top

Grog Object Model

Posted by: Joshua Smith on August 05, 2005 in response to Message #180459
Grog call model Grom for short.

Grog make up Grom by self.

Grog take SQL and put in seperate file.

Grom Good.

Grog scientist.

  Message #180787 Post reply Post reply Post reply Go to top Go to top Go to top

Teh Winnah

Posted by: Sean Malloy on August 09, 2005 in response to Message #180461
Thats the funniest thing I've read all week!

  Message #180789 Post reply Post reply Post reply Go to top Go to top Go to top

I call it the Java DAO Pattern

Posted by: Sean Malloy on August 09, 2005 in response to Message #180301
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html

I see similarities. Huge stinky ones.

  Message #180814 Post reply Post reply Post reply Go to top Go to top Go to top

Domain Objects Persistence Pattern for .NET Article Quality

Posted by: Sandu Buraga on August 10, 2005 in response to Message #180301
My opinion is that the subject is important to be discussed, since the majority of enterprise applications are using some kind of datastore, but the quality of this article is low (probably the editor is in holiday this time of the year).

First this subject is already well documented, even so if you decide to discuss it (which I think is a good thing) you should try to cover a large spectrum of sources and the article to be more like an analisys.

Also what the author propose here is well suited for small applications with a few tables and with no changing software requirements, I'd like to ask what you are going to do if you have behind more than 20 tables? for example 200 tables? you are going to hire a bunch of junior to develop, maintain and test the objects? plus effort for persistance data.

Maybe somebody decide to make an analisys and comparison between existing articles, patterns and case studies, because I repeat I think the subject is good and worth to be discussed it.

  Message #180819 Post reply Post reply Post reply Go to top Go to top Go to top

Not so bad

Posted by: Simone Chiaretta on August 10, 2005 in response to Message #180301
I agree with all of you that what the author writes about is the well know topic of the DAL, DAO, DataModel, DataMapper, HEYLTNI (HowEver You Like To Name It :-)).
But I think that it's all "zipped" in short article good to understand in a few lines why and how to implement it, without the need to understand sequence diagram or class diagram and so on.

Simo

  Message #180823 Post reply Post reply Post reply Go to top Go to top Go to top

Repositories

Posted by: Morten Mertner on August 10, 2005 in response to Message #180301
An improved version of this pattern (Repository) can be found in Eric Evans book titled Domain Driven Design.

Basically it says that persistence should be refactored out to a separate repository class that behaves much like a collection class, thus separating the persistence logic from the business class. Steve Eichert discusses the pattern in detail on his blog, and provides some useful enhancements for aggregated objects (http://steve.emxsoftware.com/Domain+Driven+Design/DDD+Aggregates++Repositories).

  Message #180829 Post reply Post reply Post reply Go to top Go to top Go to top

Other sources

Posted by: Scott Rudy on August 10, 2005 in response to Message #180341
I'll have to agree that the author needs to read Fowler's book on Enterprise Application Patterns. Also, I have found these sources to be intresting reads:

Steve Lasker's thoughts on how to implement this pattern in .Net 2.0 using the Data Adapter:
http://blogs.msdn.com/vbteam/archive/2005/04/14/TableAdaptersAndObjects.aspx


Rockford Lhotka's Expert Business Objects
http://www.lhotka.net

  Message #180854 Post reply Post reply Post reply Go to top Go to top Go to top

Don't bother mapping, go for an open source OODBMS for .NET

Posted by: Thomas Jaeger on August 10, 2005 in response to Message #180301
Have a look at the open source OODBMS "db4o" at http://www.db4o.com

Mapping a three dimensional object design to a flat, two dimensional, relational database is a waste of time and no longer needed. Actually, it’s no longer needed for many years now.

db4o supports .NET and Java. Awesome stuff if you asked me. In my 15 years of professional software engineering, a true OODBMS can save you at least 50% of development time and, more importantly, 50% of support, maintenance cost, time and headaches over the live span of an application until it is retired.

I’m always amazed how narrow minded we have become as developers and forced into this outdated, droned, “Borg”-like thinking that we should design our apps based on a database schema. This used to be funny, but, sadly, it’s become a sorry cancer in our profession.

I understand that for existing applications or applications that we inherited one way or another, a good Object Relational Mapping layer (ORM) is a compromise and the way to go until you have a chance to change the architecture.

I can go on forever; but, check out db4o. It’s very promising. I’m using it in one of my applications with C#.

  Message #181017 Post reply Post reply Post reply Go to top Go to top Go to top

gateway pattern in fowler's book

Posted by: are ski on August 11, 2005 in response to Message #180333
there is a product called RapTier that generates the factory classes in C# or VB code from reading the database schema. check the sample code from reading the Northwind database at www.sharppower.com

  Message #181045 Post reply Post reply Post reply Go to top Go to top Go to top

Such a Pity...

Posted by: Rajesh Ramesh on August 11, 2005 in response to Message #180301
Is there something new in this article? Posted in August 4, 2005 - it would have been nicer if it was 1995 or earlier! I don't know why it came in the newsletter, because of a catchy caption?

  Message #181642 Post reply Post reply Post reply Go to top Go to top Go to top

Factory vs. Mapping Objets

Posted by: Jean-Daniel Gamache on August 17, 2005 in response to Message #180301
For me, a factory should contain methods that create objects. The factory should create objects of type Customer. A factory shouldn't be used to remove or update objects.

for example ...

public class CustomerFactory : ICustomerFactory
{
    Customer CreateCustomerFromFile() { /* Implement here */ }
    Customer CreateCustomerFromDatabase() { /* Implement here */ }
}


The Old CustomerFactory class should be renamed CustomerMapper or CustomerManager. Not because of a fancy pattern but because the class is an interface between the Customer Bean and the Database.

  Message #182566 Post reply Post reply Post reply Go to top Go to top Go to top

Pointless??

Posted by: Jan Bannister on August 26, 2005 in response to Message #180301
Err...

It's this pointlessly simple. You have to throw away your object as soon as you've used it. And if 2 threads open "the same" object updates are not propagated....

This just looks like a toy example or a subset of a bigger pattern as mentioned above...

  Message #182773 Post reply Post reply Post reply Go to top Go to top Go to top

Factory pattern

Posted by: Patrik Löwendahl on August 28, 2005 in response to Message #180301
A factory Creates objects, it doesn't persist nor delete objects.

This kind of confusing articles annulates the work to try to standarize patterns and give us developers a common vacabulary.

  Message #184237 Post reply Post reply Post reply Go to top Go to top Go to top

How is it different than DAO pattern?

Posted by: Ruslan Zenin on September 13, 2005 in response to Message #180301
I've read this article and to my surprise realized that it is DAO pattern author is talking about (http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html)

Why did the author change the pattern name to "Domain Objects Persistence"?
Is he trying to "reinvent the wheel" here?

I think regardless of the platform Java, C++ or C# the patterns are stay the same. It is strange that by using another programming language, authors can justify name change of the existing and well-known patterns...

  Message #206646 Post reply Post reply Post reply Go to top Go to top Go to top

DAO and Business Logic

Posted by: Humberto Ma on April 21, 2006 in response to Message #180333
As I could read here I should separate business logic, that should be in a business class from a DAO class that implements data access methods. Business classes should not be aware of DAO classes or any other data source logic.
However sometimes it is not so clear. We have several classes here where certain methods implement both data and business logic.

Example:
[ Client ] ----> * [ DocumentHistory ] ---> 1 [ Document ]
A Client has several Documents in time. DocumentHistory stores the initial date and final date that a Document belonged to Client. ( Just like an aggregate table )

A Client has a method GetDocument(date) which returns the current Documents of a Client based on the passed datetime.

In order to do that, I should bring all DocumentHistory where initial date <= date and final date > date. For each DocumentHistory that obeys the criteria above I can get its Document and finally return the Document list.

The problem is how can I implement a method like this in Client without referencing its ClientDAO methods ?

Recent active threads Recent active threads Recent active threads More More More
[Volumes]:Buy and Sell Blackberry 8830 Housing
Transferring current project to Mysql
biztalk workflow/rule engine
I need solutions for below questions
How to data binding ADO.NET DataSet Access or SQL Server DB...
RazorSQL SQL Editor and Database Query Tool Available
Service Pack 2 for TX Text Control RapidSpell .NET 15.0 released
How to create dynamic Folded Corners effect through ImageDraw im
An Evaluation of Windward Reports
More active threads »
Top posters of the weekTop posters of the weekTop posters of the week
This list contains the members who have made the most posts in all forums over the last 7 days:
  1. muthya prasad
  2. SHERRYSLC SHERRYSLC
  3. Richardson Software
  4. Guru Talend
  5. Neodynamic Components
Hot threads Hot threads Hot threads More hot threads More hot threads More hot threads

Eclipse vs. Visual Studio at EclipseCon 2006

Speaking at EclipseCon 2006, Java developer and independent consultant Madhu Siddalingaiah compared Microsoft's Visual Studio IDE to the open source development environment of Eclipse.
(33 comments, last posted July 13, 2009)

Tech Talk: Peter Provost on CAB and Agile development

In this tech talk, Microsoft's Peter Provost talks about the design of the Composite UI Application Block and how the p&p team has led Microsoft in the adoption of Agile methodologies.
(0 comments, last posted April 17, 2006)

Book excerpt: Framework Design Guidelines

Chapter 4 of Framework Design Guidelines, titled "Type Design Guidelines," presents patterns that describe when and how to design classes, constructs and interfaces. In this chapter, Abrams and Cwalina divide types into four groups and discuss the do's and don'ts of type design.
(2 comments, last posted July 07, 2006)

Q&A: Miguel "Mono Man" De Icaza

Paul Ferrill caught up with prime open-source .NET applications driver Miguel De Icaza at Novell's BrainShare conference last week. They discussed the status of Windows Forms for Mono (it's coming along) and VB.NET for Mono (it looks like it's out).
(5 comments, last posted March 30, 2006)

Tech Talk: Jack Greenfield on software factories and DSLs

In this tech talk, Microsoft Visual Studio architect Jack Greenfield discusses the company's approach to Domain-Specific Languages, or DSLs, and the part they play in software factories.
(0 comments, last posted March 15, 2006)
More hot threads »

News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
All Content Copyright ©2007 TheServerSide Privacy Policy      Powered by JIVE
Site Map