Skip to content
Alan Maciel edited this page Sep 13, 2015 · 9 revisions

POODR Notes

Object-Oriented Design

The first requirement for learning object-oriented design is to immerse yourself in objects; once you acquire an object-oriented perspective the rest follows naturally.

Software gets build for a reason.

Design Principles

  • SOLID (Single responsibility, Open-Closed, Liskov substitution, Interface segregation, Dependency inversion)
  • DRY (Don't Repeat Yourself)
  • Law of Demeter (LoD)
  • Design Patterns

Designing Classes with a Single Responsibility

The foundation of an object-oriented system is the message, but the most visible organizational structure is the class.

The goal is to model the application, using classes, such it does what is supposed to do right now and is also easy to change later.

### Deciding what belongs in a class The problem us to know how to write the code but not knowing where to put it.

Organize the code to allow easy of changes

Definition of easy to change

  • Changes have no unexpected side effects
  • Small changes in requirements require correspondingly small changes in code.
  • Existing code is easy to reuse
  • The easiest way yo make a change is to add code that in itself is easy to change.

##### The Code should have the following qualities

  • Transparent The consequences of change should be obvious in the code that is changing and in distant code relies upon it.
  • Reasonable The cost of any change should be proportional to the benefits the change achieves.
  • Usable Existing code should be usable in new and unexpected contexts.
  • Exemplary The code itself should encourage those who change it to perpetuate these qualities.

  • Managing Dependencies
  • Creating Flexible Interfaces
  • Reducing Costs with Duck Typing
  • Acquiring Behavior Through Inheritance
  • Sharing Role Behavior with Modules
  • Combining Objects with Composition
  • Designing Cost-Effective Tests

Clone this wiki locally