I need some help to organize my data model well.
I am writing an app which will be a simple notebook. I use a three-tier architecture =
business-logic, data-logic, database access.
I`d like to use system of tags so it will be easier to search info in the app. Here are few questions
- due to separation of concerns, classes of entities and classes supporting tag search through these entities must be different. so, what is the best way to do it - encapsulation or inheritance?
- is it a good idea to separate entity classes from classes which retrieves and gives information to the database? If yes, it will be 4 levels - entity classes, database classes, tag-search helpers and BL classes.
views:
67answers:
1This are some very general questions, so I can't cover much of it.
Generally, avoid inheritance if in doubt. Inheritance should be used carefully and there are rare uses of real inheritance. Interfaces and aggregation are mostly more appropriate.
I don't understand your tag-search helpers. Tags are entities, handling of tags is business logic. Searching for entities based on tags could probably make use of interfaces and is still business logic.
What are the classes that "retrieves and gives information to the database"? Are you talking about the data access layer? I would look for some existing library or technology to access the database that fits to your needs. I'm using NHibernate, but I think this is overkill for your application. There are lots of other products around.
You need as much separation as appropriate to the complexity of your system. Not of much help, I know.