Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Limiting Scope of a Change

 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SRP (or Uncle Bob) tells us a class should only have one reason to change. Is there a name for the companion idea that a given change should affect as few classes as possible? Is that just encapsulation?

In my current system the instructions for adding a new thing X type of feature might tell how to make changes in multiple architectural layers, configuration, etc. Ick.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know it as the Single Choice Principle.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks like a good step, along with Open Closed. Maybe it's just clarifying the magnitude of the problems with this framework that it only begins to get me out of trouble.

I googled for "Single Choice Principle" and started reading something seemed just plain wrong, then glanced at the URL ... tablizer strikes again.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a good candidate for this idea ...

The principle is called "Local Change / Local Effect". It states:

Any localized design change to a software system should only require changes to a small amount of code in the immediate vicinity of the change. There should be no wide-spread or system-wide changes needed.


http://simberon.com/lcle.htm
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I usually think of loosely coupled/highly cohesive. If your classes are "loosely coupled" to one another, than a change to one is less likely to ripple through to other classes.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm thinking not so much of where a change to one class causes a change to another, but where a change to a requirement affects multiple classes. Of course we try to design abstractions to isolate change but we're gambling on what will change and what won't. Sometimes we lose?

I'm not coming up with any good examples that couldn't be cured by good abstraction and "single choice" but I have some bad examples caused by bad designs. I like "local change, local effect" to describe the objective, but in practice it looks like just good decoupling.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The principle of a single responsibility drives both aspects; so each class implements a single responsibility AND each responsibility is entirely encapsulated by a single class.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic