Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapping data

Status
Not open for further replies.

Tchami

Programmer
May 19, 2007
2
0
0
DK
Hi,

I'm designing a three-tier (Presentation-Logic-Data) application and I'm having a little trouble figuring out how to map data from my database to my custom domain objects.

As far as I see it, there's a couple of solutions for this:

1. Return the resultsets from the data-layer to the logic-layer and map resultsets to domain obejcts. Up side is that the data-layer won't know anything of how the domain objects look like. Down side is that the logic-layer will have to know column-names of the tables.

2. Map data in the data-layer to domain objects. This requires an introduction of a fourth "layer" of domain objects, as the presentation layer cannot know anything of the data-layer.Furthermore this layer of domain objects will have to be referenced from all three layers, but in turn my domain objects can be passed from layer to layer.

3. Much as number 2, but split the data-layer in two and have one part take care of getting data and another part take care of mapping the data.

I'm leaning towards the 3rd option, as I really don't want to have to change the logic-layer in case columns in the database are changed/removed.

Anyone got some advice for me?
 

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
That looks great! Thanks a lot Steve.

I'm assuming one would create the mapping files in the data-layer, right?

 
The mapping files essentially become your data layer.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Martil Fowler's book on enterprise architecture patters has a great section on data mapping and how to handle it. I highly reccommend this book.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top