According to Open Closed Principle, Software entities (Classes, modules, functions) should be OPEN for EXTENSION, CLOSED for MODIFICATION.
Lets try to reflect on the above statement- software entities once written shouldn’t be modified to add new functionality, instead one has to extend the same to add new functionality. In otherwords you don’t touch the existing modules thereby not disturbing the existing functionality, instead you extend the modules to implement the new requirement. So your code is less rigid and fragile and also extensible. (See Reference)
Lets look at the code below which draws triangle and rectangle:
Code above violates OCP principle, because if a new shape is required to be drawn, it needs change in Drawer so refactor code as below to be OCP compatible: