Clarify the Single Responsibility Principle.

Posted by dsimcha on Programmers See other posts from Programmers or by dsimcha
Published on 2010-11-05T13:34:36Z Indexed on 2010/12/29 20:00 UTC
Read the original article Hit count: 232

Filed under:
|

The Single Responsibility Principle states that a class should do one and only one thing. Some cases are pretty clear cut. Others, though, are difficult because what looks like "one thing" when viewed at a given level of abstraction may be multiple things when viewed at a lower level. I also fear that if the Single Responsibility Principle is honored at the lower levels, excessively decoupled, verbose ravioli code, where more lines are spent creating tiny classes for everything and plumbing information around than actually solving the problem at hand, can result.

How would you describe what "one thing" means? What are some concrete signs that a class really does more than "one thing"?

© Programmers or respective owner

Related posts about design

Related posts about object-oriented