Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Bob Martin wrote a series of articles on class design, which he refers to as the SOLID principles:</p> <p><a href="http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod" rel="noreferrer">http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod</a></p> <p>The principles are:</p> <ol> <li>The Single Responsibility Principle: <em>A class should have one, and only one, reason to change.</em></li> <li>The Open-Closed Principle: <em>You should be able to extend a classes behavior, without modifying it.</em></li> <li>The Liskov Substitution Principle: <em>Derived classes must be substitutable for their base classes.</em></li> <li>The Interface Segregation Principle: <em>Make fine grained interfaces that are client specific.</em></li> <li>The Dependency Inversion Principle: <em>Depend on abstractions, not on concretions.</em></li> </ol> <p>So in light of those, let's look at some of the statements:</p> <blockquote> <p>So over time the YadaYadaFile starts growing. Several overloads to save in different formats, including XML etc, and the file starts pushing towards 800 lines or so</p> </blockquote> <p>This is a first Big Red Flag: YadaYadaFile starts out with two responsibilities: 1) maintaining a section/key/value data structure, and 2) knowing how to read and write an INI-like file. So there's the first problem. Adding more file formats compounds the issue: YadaYadaFile changes when 1) the data structure changes, or 2) a file format changes, or 3) a new file format is added.</p> <p>Similarly, having a single validator for all three of those responsibilities puts too much responsibility on that single class.</p> <p>A large class is a "code smell": it's not bad in and of itself, but it very often results from something that really is bad--in this case, a class that tries to be too many things.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload