Help understanding the Single Responsibility Principle

Posted by user204588 on Stack Overflow See other posts from Stack Overflow or by user204588
Published on 2010-02-19T15:07:04Z Indexed on 2010/05/23 2:20 UTC
Read the original article Hit count: 388

Filed under:
|

I'm trying to understand what a responsibility actually is so I want to use an example of something I'm currently working on. I have a app that imports product information from one system to another system. The user of the apps gets to choose various settings for which product fields in one system that want to use in the other system.

So I have a class, say ProductImporter and it's responsibility is to import products. This class is large, probably too large.

The methods in this class are complex and would be for example, getDescription. This method doesn't simply grab a description from the other system but sets a product description based on various settings set by the user. If I were to add a setting and a new way to get a description, this class could change.

So, is that two responsibilities? Is there one that imports products and one that gets a description. It would seem this way, almost every method I have would be in it's own class and that seems like overkill.

I really need a good description of this principle because it's hard for me to completely understand. I don't want needless complexity.

© Stack Overflow or respective owner

Related posts about agile-development

Related posts about srp