Show Menu

Object-Oriented Design Principles Cheat Sheet by

Design principles mostly taken from Head First Object-Oriented Analysis & Design

Basic Principles

Encaps­ulate what varies.
Code to an interface rather than to an implem­ent­ation.
Each class in your applic­ation should have only one reason to change.
Classes are about behavior and functi­ona­lity.

Basic OO Terms

The process of separating ideas from specific instances of those ideas at work.
The provision of a single interface to entities of different types. Subtyping.
When an object or class is based on another object or class, using the same implem­ent­ation; it is a mechanism for code reuse. The relati­onships of objects or classes through inheri­tance give rise to a hierarchy.
Enclosing objects in a common interface in a way that makes them interc­han­geable, and guards their states from invalid changes

Favor the following over inheri­tance

When you hand over the respon­sib­ility for a particular task to another class or method.
Use behavior from a family of other classes, and change that behavior at runtime.
When one class is used as part of another class, but still exists outside of that other class.

Don't Repeat Yourself (DRY)

Avoid duplicate code by abstra­cting out things that are common and placing those things in a single location.

DRY is about having each piece of inform­ation and behavior in your system in a single, sensible place.

Single Respon­sib­ility Principle

Every object in your system should have a single respon­sib­ility, and all the object's services should be focused on carrying out that single respon­sib­ility.

Open-C­losed Principle

Classes should be open for extension, and closed for modifi­cation.

Liskov Substi­tution Principle (LSP)

Subtypes must be substi­tutable for their base types.

Interface Segreg­ation Principle (ISP)

Clients should not be forced to depend upon interfaces that they don't use.

Dependency Inversion Principle (DIP)

a. High level modules should not depend upon low level modules. Both should depend upon abstra­ctions.

b. Abstra­ctions should not depend upon details. Details should depend upon abstra­ctions.


Wood, David, Bert Bates, Kathy Sierra, Brett D. McLaug­hlin, Gary Pollice, and David West. Head First Object­-Or­iented Analysis and Design: A Brain Friendly Guide to Object Oriented Progra­mming. Cambridge: O'Reilly Media, Incorp­orated, 2006. Print.

"­Abs­tra­ction (computer Scienc­e)."­ Wikipedia. Wikimedia Founda­tion, 18 Apr. 2014. Web. 25 Apr. 2014. <http:/­/en.wi­kip­edi­a.o­rg/­wik­i/A­bst­rac­tio­n_(­com­put­er_­sci­ence)>

"­Pol­ymo­rphism (computer Scienc­e)."­ Wikipedia. Wikimedia Founda­tion, 25 Apr. 2014. Web. 25 Apr. 2014. <http:/­/en.wi­kip­edi­a.o­rg/­wik­i/P­oly­mor­phi­sm_­(co­mpu­ter­_sc­ience)>

"­Inh­eri­tance (objec­t-o­riented Progra­mmi­ng)." Wikipedia. Wikimedia Founda­tion, 21 Apr. 2014. Web. 25 Apr. 2014. <http:/­/en.wi­kip­edi­a.o­rg/­wik­i/I­nhe­rit­anc­e_(­obj­ect­-or­ien­ted­_pr­ogr­amming)>.

"­Enc­aps­ulation (objec­t-o­riented Progra­mmi­ng)." Wikipedia. Wikimedia Founda­tion, 21 Apr. 2014. Web. 25 Apr. 2014. <http:/­/en.wi­kip­edi­a.o­rg/­wik­i/E­nca­psu­lat­ion­_(o­bje­ct-­ori­ent­ed_­pro­gra­mming)>


Great cheat sheet!

Thanks for the comment! Glad someone finds it useful!

Thanks! It really helps.

Encapsulation at its finest :D

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Regular Expressions Cheat Sheet
          Python Cheat Sheet
          Object Oriented Design Cheat Sheet