Skip to content

lortza/design_patterns

Repository files navigation

Design Patterns (in Ruby)

This repo is a sandbox tool for me as I work my way through learning the design patterns in Ruby as described by Russ Olsen in his book Design Patterns in Ruby.

Others' Repos

Patterns

  • Adapter: An object that spans the gap between the interface you have and the interface you need. You get encapsulation at the cost of complexity.
  • Builder: Encapsulates construction logic into a class of its own.
  • Command: separate the action bits into their own object that's separate from the static bits.
  • Composite: build bigger objects out of smaller objects and allow methods to cascade. Uses 1 level of inheritance.
  • Decorator: make similar customizations to an object in an a la carte fashion at runtime.
  • Domain-Specific Languages (DSL): suggests that you should focus on the language itself, making problems easier to solve by giving the user a convenient syntax for expressing the problem. Builds on the ideas in the Interpreter Pattern.
  • Factory Method: Solving the problem of picking the right class for the circumstances.
  • Interpreter: Good for interfacing between discreet chunks of code that otherwise have trouble talking to each other
  • Iterator: iterate over objects inside of a black box
  • Observer: automatically notify observing objects when an object changes.
  • Proxy
  • Proxy: Controlling access to an object or providing location-independent access to an object.
  • Template Method: allows you to customize the steps of a process without changing the process. Uses inheritance.
  • Singleton: wip
  • Strategy: pull the algorithm out into a separate object.

Other Notes

  • Meta-programming: Takes advantage of Ruby's flexibility by allowing you to dynamically assign a class or method name at runtime.
  • Convention over Configuration: Brought to us by the Rails framework, this approach allows users (engineers) to step into a codebase and get up to speed quickly.

About

code samples for design patterns in ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages