Skip to content

Instantly share code, notes, and snippets.

@jpukg
Forked from stujo/oo-ideas.md
Created October 15, 2015 11:33
Show Gist options
  • Save jpukg/31e38a4808d3a19bfc98 to your computer and use it in GitHub Desktop.
Save jpukg/31e38a4808d3a19bfc98 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