A few days back I was reading an article on Coding Standards. There are a few articles and even books available on this topic. Following coding standards consistently, I believe is very important for a software development team. Coding standards are not written in stone. They are guidelines for making software code more readable. Like most guidelines they can be, and usually are customized for individual teams. Most teams have well defined ways in which they structure their code and name variables, methods, classes, etc. The specific standard a team adopts is not as important as the practice of ensuring that the entire team adheres to the same standard.
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