Example of principle

Report a typo

Does the pseudocode example given below follow the Open/Closed principle?

class GraphicEditor is
  method draw(Shape shape) is
    shape.draw()


interface Shape is
  method draw()


class Circle extends Shape is
  method draw() is ...

class Square extends Shape is
  method draw() is ...

Tip: With this code, the implementation of draw() method is located outside the GraphicEditor class. This allows us to avoid modifying the class.

Select one option from the list
___

Create a free account to access the full topic