Skip to content

Instantly share code, notes, and snippets.

@dsilfen-handy
Last active July 5, 2016 16:42
Show Gist options
  • Save dsilfen-handy/9fe079bc9645c4fad3e9f40ca6f300fb to your computer and use it in GitHub Desktop.
Save dsilfen-handy/9fe079bc9645c4fad3e9f40ca6f300fb to your computer and use it in GitHub Desktop.
Notes for POODR - Chapter 1

Chapter 1 - Principles of OOP

Problems to solve

  • Flexibility (The only certainty in life is change!)
  • Dependency Management
  • Cost of development
    • Avoiding design that anticipates future feature requirements

Definition of Design

  • What is design?
    • Ideas about how code should be arranged. Often with the goal to minimize the cost of change later.

Tools for Good Design

  • S.O.L.I.D.

    • Single Responsibility: Code should be responsible for doing one thing and doing it well
    • Open/Closed: Entities should be open for extension but closed for modification
    • Liskov Subsititution: A child class should be able to replace its parent class in an implementation without disrupting the program.
    • Interface Segregation: No client should be forced to depend on methods they don't use. Clients should only know about the methods that interest them.
    • Dependency Inversion: Depend on abstractions instead of specific modules. Abstractions should not depend on details, details should depend on abstractions.
  • D.R.Y.

    • Don't Repeat Yourself!
  • Law of Demeter

    • Promote loose coupling though:
      • Objects should have limit knowledge of each other
      • Objects should talk to their friends, don't talk to strangers!
      • Only talk to your immediate friends
  • The smells of good design

    • One should observe the size of classes
    • How chatty classes are
    • The depth & breadth of inheritance hierarchies
    • Number of methods invoked by a single message being sent

Design Patterns

  • Common solutions to often faced problems
    • What are some design patterns we often see used (besides MVC)?

When design fails

  • When we separate the act of design from the act of programming. Design requires fast and iterative feedback. This way we can quickly see what works and what does not. It is important to prove our designs with implementations.

When to design

  • When building software, build it in increments, and show progress sooner rather than later.

Object Oriented Design

  • Objects are a marriage between data and behavior
  • Objects respond_to messages
  • Objects decide how much data to expose to the outside world ...
  • classes are blueprints for different types of objects

Closing Question:

What parts of handybookshow exemplary OO design?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment