Articles tagged with  ruby

Duck typing vs type safety in Ruby

November 02, 2016 by Piotr Solnica

Duck typing is one of the virtues of the Ruby language, it adds a lot of flexibility to the code, and allows us to use objects of different type in places where only specific methods are needed. Even though the idea behind duck typing may seem to be...

Invalid Object Is An Anti-Pattern

December 28, 2015 by Piotr Solnica

The idea of an object that validates its own state has been made very popular by Rails’ ActiveRecord. We can see this pattern in many places, not only in ORM libraries but in many other gems whenever some sort of validation is needed.

Have you ever...

Introducing dry-validation

December 07, 2015 by Piotr Solnica

We started experimenting with a new validation library under dry-rb organization a couple of months ago, and last month I released the first version of dry-validation. Since then I worked hard on improving it and adding support for i18n.

Today, I...

Ditch Your ORM

September 18, 2015 by Piotr Solnica

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...

Encapsulating Business Transactions With Transflow

August 17, 2015 by Piotr Solnica

It’s a known fact that when you deal with a big problem it’s good to split it into smaller problems, solve them in isolation using separate components and use an integration layer to combine them into a single unit. Unfortunately it’s easier said than...

Importing Data With ROM and Transproc

July 15, 2015 by Piotr Solnica

Importing data into a database can be a complicated task. This process can be quite painful as you need to deal with data transformation, filling in missing information, specifying validation rules, handling errors and so on. Without proper tools to...

Cutting Corners or Why Rails May Kill Ruby

June 06, 2015 by Piotr Solnica

Today I’m tired and frustrated. And it’s not the first time that I have those negative feelings. Typically I just complain on twitter, lose some followers, wait a bit to calm down and move on.

But today I need to vent and convert my negative emotions...

About the new ROM release and what happens next

November 24, 2014 by Piotr Solnica

Last month I wrote about rebooting ROM project and today I’m very happy that after almost 300 commits I pushed Ruby Object Mapper 0.3.0 to It’s a big milestone as the project enters a new path and ships with a complete support for SQL...

Ruby Object Mapper Reboot

October 23, 2014 by Piotr Solnica
Rewrite is done. You can read more about it here.

I’d like to let you know that after a couple years of work and a lot of thinking I decided to “reboot” ROM project. This decision was not easy and it has a lot of implications but it’s going...

Mocking and Ruby

May 22, 2014 by Piotr Solnica

In the “TDD is dead” discussion unit testing and mocking is being mentioned frequently. DHH explicitly expressed how much he dislikes mocks and it seems like many people still connect unit testing with mocking or even confuse the two. In case you missed...

Help Us Build ROM

May 17, 2014 by Piotr Solnica

Many people have been asking me how they can help us build ROM. This was the hardest question I’ve heard next to “when will it be ready?”. My usual reply was suggesting to join our IRC channel and talk but it really isn’t a good answer as it’s difficult...

TDD Is Fun

April 23, 2014 by Piotr Solnica

Today DHH published a blog post about TDD being dead (to him at least). It’s really not that surprising since from what I know (please correct me if I’m wrong) David’s experience is mostly based on building web apps with Rails. I get that, I really...

Virtus 1.0.0 Released

October 16, 2013 by Piotr Solnica

I’m happy to announce that after 1486 commits Virtus 1.0.0 has been released. It comes with a lot of neat changes, improvements and new features.

Here’s a quick summary of my favorite additions and changes.

Mutation testing with Mutant

January 23, 2013 by Piotr Solnica

When working on DataMapper and its libraries we put a lot of effort into testing. Our libraries must have 100% code coverage and even that is not enough. What we want to achieve eventually is full mutation coverage. What is that? If you’ve ever heard...

DataMapper 2 Status and Roadmap

December 20, 2012 by Piotr Solnica
UPDATE: This article is outdated. DataMapper 2 was renamed to Ruby Object Mapper (ROM). For more info check out

We’ve been really busy working on the mapper part of DataMapper 2 for the last few months. This gives us more clarity about...

Subclassing Module For Fun and Profit

August 13, 2012 by Piotr Solnica

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...

Single Responsibility Principle on Rails Explained

July 09, 2012 by Piotr Solnica

A few weeks back we had a small drama about SRP. There were some smart comments, some stupid ones and a few funny jokes even, like that for example:

If I remember correctly it all started with...

Get Rid of That Code Smell - Attributes

April 04, 2012 by Piotr Solnica

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...

Get Rid of That Code Smell

March 30, 2012 by Piotr Solnica

While working on DataMapper 2 libraries we are measuring quality of our code with various code metric tools. Dan Kubb has been using this approach successfully for over 2 years in Veritas which resulted in a beautiful and clean code. When I started...

Yes, You Should Write Controller Tests!

February 02, 2012 by Piotr Solnica

It really surprises me that there are people arguing that writing controller tests doesn’t make sense. Probably the most common argument is that actions are covered in acceptence tests along with checking if views are properly rendered. Right? Right...

The State of Ruby ORM

November 29, 2011 by Piotr Solnica

UPDATE: DataMapper 2 was renamed to Ruby Object Mapper (ROM). For more info check out

We have a lot of different Object-Relational Mapper implementations in Ruby (and a ton and a half of Mongo mappers ;)) and it’s probably a good thing...

Making ActiveRecord Models Thin

August 01, 2011 by Piotr Solnica

“Skinny Controller, Fat Model” is a well known best practice in Ruby community. Everybody seems to agree with it and follows it. It’s pretty clear what a skinny controller is. The question is what is a fat model and what should we do if it gets too...

Custom RSpec-2 Matchers

January 14, 2011 by Piotr Solnica

RSpec is one of my favorite tools. I have literally fallen in love with this fantastic BDD library, especially with its second version. While using RSpec I realized it teaches me how to write tests. Yes, exactly - learning RSpec DSL, its syntax and...

Moving from WordPress to Jekyll

January 05, 2011 by Piotr Solnica

Hello World! As usual it’s been a while since I wrote anything here. Just wanted to say that I’m moving the site from WordPress to Jekyll and I like to share what I have learned so far. If you are considering a migration too here are the steps I have...