Invalid Object Is An Anti-Pattern

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 thought about why we’re allowing invalid state just to…validate data? It doesn’t seem to be a good idea, in fact, it feels like a huge anti-pattern....

December 28, 2015 · 4 min · Peter Solnica

Importing Data With ROM and Transproc

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 solve this problem it can become more complicated than it should be. In my current project at work I’m dealing with exactly that problem - we’re importing data from YAML documents into a PostgreSQL database....

July 15, 2015 · 9 min · Peter Solnica

Introducing Transproc - functional data transformations for Ruby

Data mapping, or how I prefer to call it - data transformations, is something I’ve tackled in a couple of projects already. First, in DataMapper ORM with its Property API. Then in Virtus, a project that started as an extraction of DataMapper Property API to a separate gem. Then Virtus evolved into something more powerful and quite a lot of people really enjoy using it until this day. The approach used in Virtus and many other libraries similar to Virtus is typical OO design....

April 16, 2015 · 4 min · Peter Solnica