D. O Sullivan
D. O Sullivan

Reputation: 199

Does the decorator pattern violate the SRP?

I've heard a number of sources state that the decorator pattern violates the single responsibility principle. Me (being new to design patterns) am unsure how.

Does the decorator design pattern violate the single responsibility principle? And if so, how?

Cheers

Upvotes: 2

Views: 522

Answers (1)

mawalker
mawalker

Reputation: 2070

No...

https://en.wikipedia.org/wiki/Decorator_pattern even states:

The decorator pattern is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern.

....So I'd be even more curious to see your 'sources'.

Speaking of... when asking a question like this, when you say "several sources" it should be a hint for you to list them and then do a little bit to compare and contrast them. This will help others to see the nuance of the question you are asking, or debunk it entirely... but either way to help you answer your question.

Upvotes: 3

Related Questions