Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #6300

Thoughts on the Single Responsibility Principle.

From Daniel Pitts <usenet@coloraura.com>
Newsgroups comp.programming
Subject Thoughts on the Single Responsibility Principle.
Date 2016-03-06 20:25 -0800
Organization A noiseless patient Spider
Message-ID <nbivme$j6j$1@dont-email.me> (permalink)

Show all headers | View raw


Hello,
I was recently thinking about the Single Responsibility Principle, and 
one of the thoughts I had was that it an be applied to *all* levels of 
software crafting.

I think it is relatively self-evident that methods/functions should "do 
one thing", and that classes should "encapsulate one concept".

But, I want to take the idea further.  Namespaces/packages should 
contain only things relevant to one responsibility.  And a "Project" 
should also be limited in its responsibility.

The difference is that the smaller the scope, the more specific the 
responsibility should be.

For example, a projects responsibility might be "Provide email access", 
a package in that project might be "provide SMTP support", a class in 
that package might be a "Manage SMTP Connection", and a method on that 
class might have the responsibility of "Send authentication".

I'd even say that statements (in imperative languages) should also have 
one responsibility.  This means statements such as "foo = ++bar;" are 
breaking the SRP, as the statement is responsible for incrementing bar 
*and* copying the result to foo.

Maybe what I'm saying here is so self-evident that I shouldn't have 
brought it up, or maybe what I'm saying is just plain wrong, or even 
oversimplified.  I'd like feedback.

Thanks,
Daniel.

Back to comp.programming | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Thoughts on the Single Responsibility Principle. Daniel Pitts <usenet@coloraura.com> - 2016-03-06 20:25 -0800
  Re: Thoughts on the Single Responsibility Principle. "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2016-03-07 09:23 +0100
  Re: Thoughts on the Single Responsibility Principle. Richard Heathfield <rjh@cpax.org.uk> - 2016-03-07 14:49 +0000
  Re: Thoughts on the Single Responsibility Principle. Julio Di Egidio <julio@diegidio.name> - 2016-03-07 08:58 -0800
  Re: Thoughts on the Single Responsibility Principle. Jos V <xjosx@xjosaphatx.co> - 2016-03-09 00:30 -0500
    Re: Thoughts on the Single Responsibility Principle. Julio Di Egidio <julio@diegidio.name> - 2016-03-09 06:48 -0800

csiph-web