I've got a question involving the best way to design an OO problem. Say you've got an object Employee that is so massive that you decide for it to contain smaller objects (like WorkStatistics and PersonalInfo) for better manageability. Now my question is, what is better: to nest these objects inside the Employee object or to declare them in the outside interface object and include pointers that point to the employee they are referencing? I've seen both done but to me they both have their drawbacks. Like for example, if you have many nested objects its a pain to get at the lowest one from the outside world like so:Exagerated, but I hope you understand what I mean! But on the other hand, declared outside with pointers can be a real pain, not to mention hard to read...Code:// I couldn't think of a better example off the top of my head! // Just imagine each object being massive so as needed to be // broken up string Employee::returnFavOutdoorHobby() { return myPersonalInfo.returnFavOutdoorHobby(); } string PersonalInfo::returnFavOutdoorHobby() { return myHobbies.returnFavOutdoor(); } string Hobbies::returnFavOutdoor() { return myOutdoor.returnFavorite(); } string Outdoor::returnFavorite(); { return Favorite; }Anyone know how something like this is usually approached in a real world situation?



LinkBack URL
About LinkBacks
Anyone know how something like this is usually approached in a real world situation? 



I simply meant that an instance is declared within another class, not the class itself actually being declared within another class. Do you think this is not very OOP either? But you definately make some great points either way, and you're right, it's not very hard to write those extra functions even if they are redundant!