Chapter 1 Notes on Design Patterns in Ruby by Russ Olsen

Created on Jun 23, 2021

Part I: Patterns and Ruby

Chapter 1: Building Better Programs with Patterns

The first few times we see a problem we may improvise and invent a solution on the spot, but if that same problem keeps reappearing, we will come up with a standard operating procedure to cover it. Don’t, as the old saying goes, keep reinventing the wheel.

Say we want to create a class for cars and a method of driving:

my_car =

and then we wanted to add airplane as well:

if is_car
    my_car =
    my_plane =

The problem here is that we focused on the implementation, not the interface.

From the interface point of view, we will consider just one class that would be helpful when we ever think of adding trains, or any other vehicle. Something like:

my_vehicle = get_vehicle

Design patterns are all about making your systems more flexible, more able to roll smoothly with change.

Final Thoughts

In this chapter, the author justifies why learning design patterns is important for building better software programs. Although this book in Ruby language, the author makes it easy for beginners in the language. Stay tuned because if you are a Ruby beginner, the next chapter will come to your rescue.

See you in chapter 2 notes!

Get Design Patterns in Ruby from Amazon!!

Design Patterns in Ruby by RussOlsen

Image by the Author

Get the next FREE ebook ‘Disciplined’ once released and more exclusive offers in your inbox

Published on medium