Assume you have a class. It can really be any class that defines a domain concept like an employee, a product on an e-commerce site, or a car. One of those examples that are oldies but goodies. According to the SRP, that object should be responsible all of "its" things.
I would consider an employee taking a lunch, a product going on sale, or a car accelerating all examples of things that "belong" to those examples. This can include other categorical areas of concern such as affecting the database, firing an event, or changing a simulation while the source object is still responsible for the overall outcome.
The struggle I see there is you either have very flat architectures where an object can (potentially) touch anything or you have rather verbose layers of abstraction that the objects can reasonably rely on. However, the latter feels more like giving up responsibility the more layers there are between a thing and what it's trying to do.
I really don't know where I stand on this, personally. I'd quite likely compromise by splitting the baby, as it were, in most of those scenarios which feels some kind of wrong no matter what I do. Being the middle of 2015, has there been any development toward these kinds of problems that give good guides on where one should be?
I understand the composition over inheritance advice in object construction but when you're formulating ideas and not building objects yet, is there a clear "good" way to go about this?
Edit: So, with the potential duplication of Is SRP (Single Responsibility Principle) objective?, I don't think that's the case. I'm not implying it is or even should be objective. I'm curious if there have been improvements in schools of thought around this subject. I get it's subjective. To illustrate: I don't think anyone would say writing software has one, objectively correct method, but SOLID is often given as a guide to write "good" software. Similarly, given SOLID, where is the thought-space around the SRP and object ownership?
object
, for example? Thestring
class alone has a collection of things it does that changes strings. Or, do you mean to say the "one thing" can exist at different abstraction levels (i.e. a class to "manage strings" vs. one to concat two strings)? In that case, how am I misunderstanding the SRP? – Bigsby Jul 31 '15 at 18:52