If your class has to do several things, then it may help to break it down into sub-classes.
Consider a container that is a hash table using filesystem storage. It may be useful to create a subclass that stores a single item in the filesystem. Now, create a hash table class that stores the filesystem objects. You can debug each class separately, and each class does only one thing.
We didn’t evolve to do object-oriented programming. Our brains aren’t designed to do this sort of thing. They’re not very good at it. Therefore, keep each class simple & managable.
“Having two classes will increase overhead.”
May I see your profiling data? Oh, you don’t have any? Yeah, I thought so. Your intuition is a poor guide, here.
“But I don’t want to write two classes!”
If you’re afraid of writing classes, then C++ is not for you. Practice the phrase, “Can I supersize that for you?”
Modified: 2014-05-07T09:27 User: Guest Check: HTML CSSEdit History Source |
Apply to CSU |
Contact CSU |
Disclaimer |
Equal Opportunity Colorado State University, Fort Collins, CO 80523 USA © 2015 Colorado State University |