4 ms·
I've always found a good principle to be that functions should do something and classes should be something and it should be possible to explain what that somet
by dspeyer 17y ago
I've always found a good principle to be that functions should do something and classes should be something and it should be possible to explain what that something is in a short sentence. If an if or switch statement can become a map of function pointers or a polymorphic dispatch without violating this principle, go for it. If not, use "if". Even if you have to use a lot of "if", it'll make your code make sense.
A related principle is that a function's argument list should never be longer than its body.