Searched for ""

Three Days with Sandi Metz on Practical Object-Oriented Design

Last month, I attended Sandi Metz’s three-day Practical Object-Oriented Design Course in Durham, NC. The course totally exceeded my high expectations. I felt very lucky and glad that I decided to go. It was one of the best things that happened to me this year.   In this post, I will share: why I decided to make this big investment what happened in those three days what happened after the course how can you learn these course materials   1. Why I decided to spend time and ??? on this course I first knew about Sandi Metz through her book Practical Object-Oriented… Continue reading

Design Pattern: Iterator and Movie Collections

Design Patterns in life and Ruby — gain an intuitive understanding of OO design patterns by linking them with real-life examples.   The Iterator Pattern answers this question: What’s next? In English, an iterator returns items from a collection one at a time until it has returned all items from the collection. Let’s use the Iterator Pattern to build our movie collection. Let’s pretend we have subscriptions for both Netflix and Amazon Prime. Our goal is to combine all the movies on Netflix and Amazon Prime to build our movie collection. We can ask Netflix for a list of available… Continue reading

Design Pattern: Facade and 1-Click Ordering

Design Patterns in life and Ruby — gain an intuitive understanding of OO design patterns by linking them with real-life examples.   The Facade Pattern is about making complicated things simple.   You will know exactly what the definition means after we do some shopping on Amazon.   Shopping on Amazon is similar to shopping anywhere else online. You first add an item to your shopping cart. You then proceed to the checkout process, which has four steps: Enter Shipping Address Enter Payment Method Review Items and Shipping Place Order Here is what the code will look like: class CheckoutProcess… Continue reading

Object-Oriented Design Patterns in Life

Object-Oriented Design Patterns in Life Many programming concepts are inspired by the physical world we live in. Object-oriented design patterns are no exception. Join me on the journey of learning object-oriented design patterns by recognizing them in day-to-day life. Each post in the series maps a design pattern with a real-life example. You will be surprised by how many oo design patterns you have been using in everyday life: Love burgers? You already know the Strategy Pattern. Love Chipotle? That’s the Template Method Pattern. Can’t live without Amazon? The Facade Pattern is your friend.   Subscribe so you won’t miss the next post! Creational Patterns Factory & Cheesecake Factory… Continue reading

Design Pattern: Adapter and Power Adapter

Design Patterns in life and Ruby — gain an intuitive understanding of OO design patterns by linking them with real-life examples.   The Adapter Pattern is very easy to understand because we interact with it every single day.   If we search for adapter images online, we will see lots of real-life examples using the Adapter Pattern.   Type C to Type A Power Adapter Let’s take a closer look at one of these real-life examples — Type C to Type A Power Adapter. The Type A electrical outlet plug is widely used in the US, whereas Type C is widely… Continue reading

Design Pattern: Command and Concierge

Design Patterns in life and Ruby — gain an intuitive understanding of OO design patterns by linking them with real-life examples.   The Command Pattern’s definition is a stressful one to look at.   Let’s forget about it for a second and take a trip to Hawaii. And live in a luxury hotel.   We spent the day on the beach, scuba dived, and did some sightseeing. It’s time to get back to the hotel to chill, eat, and plan for the next day.   After getting back to the hotel, we want to: Get room service for dinner Get… Continue reading

Who are you? Self-awareness In Ruby

Understanding how self works is critical in reading Ruby code. If you ever feel confused or lost when reading a piece of Ruby code, exam what is self in the current context might get you back on track. It’s one of those things that once you get it, many Ruby codes will start making sense to you. This article explains: what is self how to determine self What Is Self? Being the default object of the current context gives self two privileges. It is the default receiver of messages, meaning calling a_method is the same as calling self.a_method.  It is the owner of instance… Continue reading

Design Pattern: Singleton and YOU

Design patterns in life and Ruby — gain an intuitive understanding of OO design patterns by linking them with real-life examples.   This might be the most important post in my Design Pattern series because this one is about YOU. Before anything, you need to listen to this song: No, I’m serious. The song is less than 2 minutes. Listened to the song before you read any further. Let’s take a look at the lyrics of the song:   You’re in a class by yourself, you’re one of a kind, and you’re the one and only one! This uniqueness is… Continue reading

Design Pattern: Observer and Podcasts

Design patterns in life and Ruby — gain an intuitive understanding of OO design patterns by linking them with real-life examples.   If you listen to podcasts, you are already familiar with the Observer pattern. In fact, you are an “observer”. Here’s the definition for the Observer pattern:   Let’s look at the definition as related to podcasts. I find an interesting podcast named developer tea. After clicking the SUBSCRIBE button, I’m now on their subscriber list.   When developer tea releases a new episode, the Podcasts app will notify me and other subscribers and automatically download the new episode for… Continue reading