Skip to content

Instantly share code, notes, and snippets.

@stujo
Created May 5, 2015 20:57
Show Gist options
  • Save stujo/78798dab0e4d5426847b to your computer and use it in GitHub Desktop.
Save stujo/78798dab0e4d5426847b to your computer and use it in GitHub Desktop.

Object Oriented Ideas

Why

  • Represent our ideas
  • Manage Complexity

Generic OO Terms

  • Abstraction - Figuring out what abstractions express our requirements
  • Polymorphism - Using multiple abstractions in the same way
  • Inheritance - Sharing Implementation
  • Encapsulation - Hiding Implementation Details

OO Implementation Details

  • Objects - Instances of Classes
  • Mixins - module and include
  • Interfaces - Set of Public Methods
  • Classes - Object Factories
  • State - Instance Variables
  • Behaviours - Methods and Implementations
  • Abstract Class - An Incomplete Class
  • Duck Typing - Presence of a quack method

Design Considerations

  • Single Responsibility - Objects and Methods
  • Law Demeter - Don't reach inside other objects
  • What vs How - Interface specifies what to do not how

Composition vs Aggregation

  • Stack Exchange
  • Composition - A Composition of Owned Components
  • Aggregation - An Aggregation of Independent Parts

Guidelines

  • Think about Interface before Implementation
  • Abstraction - Only add the State and Behaviour you need
  • If Objects are the Cookies, Classes are the Cookie Cutters

Resources

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