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... :confused: Anyone know how something like this is usually approached in a real world situation?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;
}