Posts

Design Principles

Here are some of the basic design principles that one should keep in mind while developing applications. The Open Closed Principle (OCP) A module should be open for extension but closed for modification We should write our modules so that they can be extended, without requiring them to be modified. In other words, we want to be able to change what the modules do, without changing the source code of the modules The Liskov Substitution Principle (LSP)   Subclasses should be substitutable for their base classes That is, a user of a base class should continue to function properly if a derivative of that base class is passed to it Restating the LSP, we can say that, in order to be substitutable, the contract of the base class must be honored by the derived class Restating the LSP once again, this time in terms of the contracts, a derived class is substitutable for its base class if: 1. Its pre-conditions are no stronger than the base