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?
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?