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


Groups > comp.programming > #6301

Re: Thoughts on the Single Responsibility Principle.

From "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Newsgroups comp.programming
Subject Re: Thoughts on the Single Responsibility Principle.
Date 2016-03-07 09:23 +0100
Organization Aioe.org NNTP Server
Message-ID <nbjdrj$1olk$1@gioia.aioe.org> (permalink)
References <nbivme$j6j$1@dont-email.me>

Show all headers | View raw


On 07/03/2016 05:25, Daniel Pitts wrote:

> 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".

Self evident also is that this does not work for no less evident 
reasons. But otherwise appropriately formulated, Occam's razor works for 
SW design.

> 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.

Nope. That depends on the concept here. The concept can well be 
"increment and copy" indivisibly. E.g. in concurrent programming atomic 
increment+latch is an important fundamental concept.

The morale is, the "concept" is the problem space entity. Otherwise, 
when considered in isolation it is pretty much arbitrary. What is single 
responsibility in one context could be multiple in another as you move 
along abstraction levels and computational frameworks.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Back to comp.programming | Previous | Next — Previous in thread | 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