In my application design, I usually map objects to the important tables in the database. The objects then handle everything relating to that data (including linkage tables). So I for example have built an Activity object, with properties like name and due_date, methods like load() and save(), and also methods like getParent(), getContributors() and getTeam(), which return (arrays of) other objects. Is this ‘bad’ OOP because it violates the Single Responsibility Principle?
In my application design, I usually map objects to the important tables in the
Share
It depends on the situation and the exact code you have: Your design might touch multiple responsibilities and still be a pretty nice OOP and maintainable.
Do you handle
load()andsave()in each class with similar code? Or do you delegate the task withinload()andsave()to other objects that are used for this functionality in several classes? That would be half-what following SRP and still be according to your design.If not, your code really seems a bit smelly. To check whether it covers multiple responsibilities, ask yourself: what could cause changes to my class? In your situation, I would at least try to refactor the similar code in
load()andsave()in different classes to reach the situation described above, so that