title: How to build stuff objects using the decorator pattern?
body: <p>I have some questions regarding the decorator pattern. As I have understood it, the decorator pattern exists to add behaviour to an object, ie &quot;decorating the object&quot; so you can compose different objects without the need of implementing lots of lots of different classes with small changes, leading to a &quot;class explosion&quot;.</p>
  <p>Now the thing is, the decorator pattern generalised says the we should have a base class which our decorator class then extends, but also delegates from. So the decorator essentially both &quot;is a&quot; and &quot;has a&quot; base class (and with that it's methods).</p>
  <p>And there comes the problem, because let us say I want to compose a &quot;player&quot; for a game, many different players actually and all with small changes. Then I might want to use the decorator pattern(?) and say &quot;okay our base class is a normal human&quot;. I want to decorate this human with a gun and with body armor. Then my decorator class gun will implement the same methods that the human has, let us say &quot;eat&quot;. But surely my gun won't eat, I only want it to be able to shoot. And I can fix that by just returning null or something but that would also break the Interface Segregation Principle.</p>
  <p>So how would I then solve this without breaking the ISP while also not needing to create tons of classes with minimal changes, for example &quot;human with gun&quot;, &quot;human with gun and body armor&quot;, &quot;human with staff and body armor&quot;, &quot;human with staff&quot;, you get the idea.</p>