FAQ Database Discussion Community

What is a Refused Bequest?

Could someone please explain what does Refused Bequest means? I tried reading some articles and says its a kind of code smell or in wiki it tells that it is a class that overrides a method of a base class in such a way that the contract of the base...

What am I misunderstanding about the Liskov Substitution Principle

I thought I understand the LSP, but it seems I'm totally wrong. I have the following classes: class PrimitiveValue { } class StringValue extends PrimitiveValue { } class A { public function foo(StringValue $value) { } } class B extends A { public function foo(PrimitiveValue $value) { } } Note...

How to write an ImmutableMap that follows the Lisvok Subsitution and other SOLID principles without code smells?

I answered a question regaurding an ImmutableMap. I suggested using the Proxy pattern. The problem with this is that Map contains a put method, which would throw an UnsupportedOperationException. Replacing other instances of Map with ImmutableMap would break the Liskov Subsitution principle. Not only that, the need to declare put...