Daniel Duffy
C++ author, trainer
- Joined
- 10/4/07
- Messages
- 10,470
- Points
- 648
One-liners in OOP
1. Multiple inheritance was not a good idea. C++ does not support interface keyword. The AI community used MI a lot in the 90s.
2. Not evertyhing is an object. Behavioural commonality is not structural commonality.This messes up class hierarchies.
3. Deep class hierarchies are usually incorrect and not maintainable, especially with MI. For CAD, all you need is depth 1 and make sure each class has 1 major responsibility. Combine with composition and Visitor pattern. Separation of Concerns is key!
4. "Tiny classes" are not classes; they are not even objects. Just think of many many Command classes. Just use lambda functions.
5. Virtual functions and multiple classes are not needed; instead, use a single class with one or more std::function instances.
6. (Sapir-Whorf) At the time. some developers used GOF patterns left, right and centre. What happened in many cases is life started with the (GOF) solution and work back to the problem. Like Newton-Raphson, convergence is not a given.
7. Classes are context-sensitive (aka unstable). Many classes live in the head of their creator who may have incomplete information about the problem domain.
8. Our group had 1-7 on our radar screens for some time. Especially for fixed-priced projects. For developers on an hourly rate things can be slightly different. Parkinson's Law and gold-plating might kick in.
9. Class hierarchies are neither sufficient nor necessary.
1. Multiple inheritance was not a good idea. C++ does not support interface keyword. The AI community used MI a lot in the 90s.
2. Not evertyhing is an object. Behavioural commonality is not structural commonality.This messes up class hierarchies.
3. Deep class hierarchies are usually incorrect and not maintainable, especially with MI. For CAD, all you need is depth 1 and make sure each class has 1 major responsibility. Combine with composition and Visitor pattern. Separation of Concerns is key!
4. "Tiny classes" are not classes; they are not even objects. Just think of many many Command classes. Just use lambda functions.
5. Virtual functions and multiple classes are not needed; instead, use a single class with one or more std::function instances.
6. (Sapir-Whorf) At the time. some developers used GOF patterns left, right and centre. What happened in many cases is life started with the (GOF) solution and work back to the problem. Like Newton-Raphson, convergence is not a given.
7. Classes are context-sensitive (aka unstable). Many classes live in the head of their creator who may have incomplete information about the problem domain.
8. Our group had 1-7 on our radar screens for some time. Especially for fixed-priced projects. For developers on an hourly rate things can be slightly different. Parkinson's Law and gold-plating might kick in.
9. Class hierarchies are neither sufficient nor necessary.