& Robert C. Martin Understand the Problem and various Code Smells How OCP comes to the rescue? Understand Fundamental Concepts Exception scenarios for OCP Principle How to refactor your code using OCP?
e ers as virtual is Ope to E te sio . Virtual methods have an implementation but can be overridden in the derived class. Virtual method Abstract method Can provide a default implementation. Cannot have an implementation. If it is good enough, Child classes can use it or else override it. Child class must give their own implementation. Can exist on abstract or non- abstract class. Can only exist on an abstract class.
declarations. Interfaces describe functionality whereas Class describes traits. Interfaces separate definition of objects from its implementation. Interfaces helps to develop loosely coupled systems. X Y X Y Interface
reak No need to change working code No need to fix broken unit tests New classes have no legacy coupling, hence less likely to create issues Move changes to Production faster. Build code that allows changes over time