Last post Feb 25, 2011 01:23 PM by fpl
Feb 22, 2011 06:29 AM|a.starreveld|LINK
Because i've never done anything with overriding, i started a new project. The project itself does not really serve a purpouse, but i'm mostly trying to learn new things. That's why i'd very much apreciate your advice. I decited to use the following architecture:
- I created a core code library. This library contains my domain objects. It just says: A person has the property: Age, firstname, lastname, etc. But the person might have a partner too.
- Then i created a data code library too. In this code library i created a class person too. It inherits the properties from the core.Person object (Age, surname, lastname, partner). In this example, it would override the person Partner property of the person.
In the get I selected the partner details from the database. (It's not real efficient, i know. But it's just for practacing.)
- Then i extracted an interface of the person object and i created an ascx (custom control) which inherits this interface. The data.Person and the core.Person inherit from this interface too.
- Now i want to be able to save both the data.Person and the web.Person (ascx control) into my database.
How do i do this with the minimal ammount of code? Can you guys point me in the right direction?
I hope you all are able to help me out.
Feb 25, 2011 01:23 PM|fpl|LINK
If I understood well what you are trying to do, here are my thoughts on this
Usually I take a slightly different approach. From my point of view, the data store is the dumbest of all your layers. In your case it would just store for a person attributes like age, name, etc and at most a relationship (a pointer, constraint, you name
it) to another person (the partner). Then your core library has entities like person and all the rich and vast OOP you would like to add. This core library as its name says holds all your core business logic for your problem domain. Then I would have your
core Person class inherit from your data store Person class. Your custom control via inheritance or interfaces could access your core Person class.
I know what I am saying it is not exactly what you want to acomplish but I think it makes more sense: The only thing important to store in database is just persons and their basic relationships. All the the rest is better to maintian it in your core library.