Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Improve your software with SOLID code

Improve your software with SOLID code

You might have heard of the acronym SOLID and the five principles it consists of. Sadly the concepts are very abstract and can be difficult to really understand, while they are so important to writing good object oriented code.

This talk will not only deal with the theory behind SOLID and explain why SOLID is important. Better yet, we will be looking at code (lots of it!) and how it can be improved by applying one of the SOLID principles.

flijten

May 02, 2012
Tweet

More Decks by flijten

Other Decks in Programming

Transcript

  1. Open Closed Principle Software entities (classes, modules, functions, etc) should

    be open for extension, but closed for modification.
  2. There may be no more than one switch statement for

    a given type of selection. The cases in that switch statement must create polymorphic objects that take the place of such switch statements in the rest of the system
  3. Open Closed Principle 1. Since changing code introduces errors 2.

    Try to minimize change 3. And use polymorphism to solve our problems
  4. Liskov Substitution Principle Functions that use pointers or references to

    base classes must be able to use objects of derived classes without knowing it
  5. Liskov Substitution Principle 1. Indispensable when adhering to the OCP

    2. Only when a subclass can be used as its parent in every respect, functions using that parents can be reused without impunity.
  6. Dependency Inversion Principle A. High-level modules should not depend on

    low level modules. Both should depend on abstractions. B. Abstractions should not depend upon details. Details should depend upon abstractions.