As system architects we have to foresee things that can change in the software specification over time. We have learned that a good system design is one that seperates the things that change from the things that do not. However in trying to foresee potential changes we often try to design for changes that may not happen. This leads to an over-engineered design which is more time consuming to implement and difficult to understand. Such a design becomes counter productive. While designing a software it is important to view the changes we anticipate along with their probablity of occurence. It is often a good idea not to design for a low probability change, if it significantly increases the design complexity.
I am reading the excellent Django book right now. In the 4th chapter on Django templates , there is an example of includes and inheritance in Django templates. Without going into details about Django templates, the include is very similar to composition where we can include the text of another template for evaluation. Inheritance in Django templates works in a way similar to object inheritance. Django templates can specify certain blocks which can be redefined in subtemplates. The subtemplates use the rest of the parent template as is. Now we have all learned that inheritance is used when we have a is-a relationship between classes, and composition is used when we have a contains-a relationship. This is absolutely right, but while reading about Django templates, I just realized another pattern in these relationships. This is really simple and perhaps many of you may have already have had this insight... We use inheritance when we want to allow reuse of the bulk of one object in other ...
Comments