Open close principle (OCP)
This is known as open for extension and closed for modifications. A class can be better implemented as abstract & derived forms so that if any changes needs to be made it can be made to the derived functionality instead of changing core base class. A bad implementation example is Shape class that draws rectangles, ellipses, circles. If it needs to draw a square then a new drawSquare() function needs to be added. This is bad design because as the class is changed all of it needs to be unit tested again, if this is imagined as big class there are problems with multiple developers working simultaneously needs to integrate it and a change might break the code somewhere. A good design is splitting the shape in to one Shape base class with abstract drawShpe() and multiple derived classes like Ellipse, Circle, Rectangles overriding implementation which fits in to OCP...
Dependency Inversion Principle
Content in development..............................
WARNING: ALL CONTENTS HERE ARE MY PERSONAL INTERPRETATIONS. THERE IS NO WARRANTY GUARANTY ABOUT RELIABILITY OF CONCERNED MATTER
No comments:
Post a Comment