The coding standards are the least of your worries!
The coding standards are the least of your worries!
Posted Jun 1, 2010 22:45 UTC (Tue) by Tobu (subscriber, #24111)In reply to: The coding standards are the least of your worries! by rev
Parent article: GCC begins move to C++
Good guidelines. I especially agree with the ones about keeping variables private not making things mutable lightly.
I'd like to amend the rule about multiple inheritance though; besides an optional base class, it is perfectly fine to inherit from a number of mixins. For example, any class that deals with a non-copyable system resource (such as a socket) should add boost::noncopyable (or the local equivalent) to its parents. And I recall friends can help making data more private to the world at large, and should be allowed to help write things like output operators that are closely related to the class.
Posted Jun 2, 2010 20:18 UTC (Wed)
by rev (guest, #15082)
[Link]
Surely. These are guidelines. And my list is not complete I might add. I like to formulate them a bit strict. Firstly to make them clear. Secondly to steer programmers with little OO experience away from the abuse their instinct seems to drives them to. You are allowed to break the rules when you understand them a kind of being the motto.
There will always be situations where we have to break the rules. Rules cannot deal 100% with all the details a quirks of reality.
And, of course, there are always situations where the nature of the underlying problem is such that deviation from the rules is the required solution, such as building a class hierarchy, or using friends.
The coding standards are the least of your worries!