Skip to content
/ SOLID Public

Source code for my presentation on code design and the SOLID principles

Notifications You must be signed in to change notification settings

mbrennan/SOLID

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository contains the source code for the basis of my presentation entitled "Code Design & the SOLID Principles."  It is structured in a way to easily allow progression through each principle, refactoring the source base along the way into a better version of itself.

Because I didn't want to teach TDD/BDD in this session, and because I'm intending to use this presentation as the basis for a future TDD/BDD presentation, there is no test suite included within the project.

The example code represents a command line directory size counter.  It can report the top 10 largest directories, recursively, within a base directory; or the top 10 largest file types, recursively within a directory.

There are several branches in the repository to make navigation within the presentation simple, and to illustrate the changes between one principle to the next:

Branches:
initial_code - Represents the initial, extremely messed up version of the source base
SRP1         - Cleans up variable names, moves code into seperate methods, adds guard clauses
SRP2         - Moves code into seperate classes to further adhere to SRP
OCP          - Makes the code easier to add different types of size calculators or summarizers
LSP          - Removes the violation of LSP in ConsoleDisplayer
ISP          - Removes the violation of ISP in ISummarizer
DIP          - Splits business logic into separate library; removes dependency in calculators on console switches

For a refresher, the SOLID principles state the following:

S - Single Responsibility Principle (SRP)
There should never be more than one reason for an object to change

O - Open/Closed Principle (OCP)
An object should be open for extension but closed for modification

L - Liskov Substituion Principle (LSP)
References to objects must be able to use a more specialized object without knowing it

I - Interface Segregation Principle (ISP)
Objects should not be forced to depend upon interfaces they do not use

D - Dependency Inversion Principle (DIP)
Higher-level modules should not depend upon lower level modules; both should depend upon abstractions
Abstractions should not depend upon details; details should depend upon abstractions

Please see http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod for more information on the SOLID principles.

About

Source code for my presentation on code design and the SOLID principles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published