Presuming I have a class named A, and I want to use the decorator design pattern. Correct me if I\'m wrong, but for that to work , we\'ll need to create a decor
In some languages (like Ruby or JavaScript) you could just add new functionality to an A instance. I notice that your question is tagged Java, so I assume that you are asking why you can't do this in Java. The reason is that Java is statically typed. An A instance can only ever have the methods that class A defines or inherits. Therefore, if you want at run time to give an A instance a method that A does not define, then this new method must be defined in a different class.