design-patterns-csharp icon indicating copy to clipboard operation
design-patterns-csharp copied to clipboard

Liskov substitution principle violation

Open dotsquid opened this issue 3 years ago • 1 comments

Hi. First of all thanks for an amazing "refactoring.guru" resource. It's definitely a great contribution to global IT education. However, I think that this example violates the Liskov substitution principle since the Leaf class does not properly implement Add and Remove methods of the base Component class. As such you had to use IsComposite method and call it in the client code.

dotsquid avatar Mar 26 '21 12:03 dotsquid

Here is my humble attempt to fix it https://github.com/RefactoringGuru/design-patterns-csharp/pull/6

dotsquid avatar Mar 26 '21 12:03 dotsquid