Commonality and variability

I just finished Jim Coplien’s Multi-Paradigm Design for C++. While I found it a little too theoretic for my taste (sometimes I think I’m stupid, but there’s been some evidence to the contrary, so I assume the book was just difficult), it presented some concepts I thought would be interesting to investigate further.

As I understood Coplien, the fact that C++ supports multiple paradigms is mostly useful to the extent that these paradigms (object-orientation, templates, procedures, preprocessor) can be used to express commonality and variability in designs.

Commonality forms families or type hierarchies in traditional OO. For C++ generic programming, a commonality could be expressed as a template.

Variability, on the other hand, is what disambiguates the family members from each other. Again, in the OO setting, this is typically derived, concrete classes, whereas for templates it’s the actual template arguments that cause the specialization.

I think these concepts may actually be very useful in thinking about designs, and how to express them. Coplien’s work postdates the seminal work on Design Patterns, but I believe commonality/variability analysis can be of help in forming, understanding and recognizing patterns.

All in all, I thought the book was pretty hard to digest, but it added some kind of meta-conscience to my design sense. I think I’ll be able to think in terms of commonality and variability to explore solutions to design problems more freely. Given time and energy, I’m going to see what else has been written on commonality/variability outside of the multi-paradigm design space, and keep reading.