oop

Ditch Your ORM

I’ve been promoting a functional approach in Ruby for a while now and even though it includes many different techniques and patterns, there’s this one idea, one fundamental idea that changes everything – immutability. But what does it even mean in Ruby? To freeze everything? That would be too slow,...

Continue reading...

Subclassing Module For Fun and Profit

You think you’ve done everything with Ruby? How about subclassing Module? It’s an interesting technique that I’ve been experimenting with lately. One of the downsides of using modules in Ruby is that a module doesn’t have a state. When you mix it into another class you’re basically copying methods from...

Continue reading...

Get Rid of That Code Smell – Primitive Obsession

This is a post from the Get Rid of That Code Smell series. Primitive Obsession is another popular code smell in Ruby land. It’s very easy, tempting and just feels convenient to use primitive objects to represent various concepts in our code. Here are some primitive classes in Ruby that...

Continue reading...

Get Rid of That Code Smell – Duplication

This is a post from the Get Rid of That Code Smell series. Removing duplication from the code is a seemingly easy task. In many cases it is pretty straight-forward – you look at similar bits of code and you move them to a common method or class that is...

Continue reading...

Get Rid of That Code Smell – Control Couple

This is a post from the Get Rid of That Code Smell series. If you are serious about Object Oriented Design and respecting Single Responsibility Principle then you definitely want to get rid of Control Couple code smells. In this post I will show you a simple example explaining how...

Continue reading...

Get Rid of That Code Smell – Attributes

In this post I will show you why using attribute accessors is a code smell in most of the cases. This is a very convenient feature of Ruby but you should only consider using it if you’re implementing a data-like objects which expose, well, data to other parts of your...

Continue reading...