ORM: Active Record vs. Data Mapper

Everybody building a web application with a modern framework, is already probably using an ORM (Object-Relational Mapping).  Most frameworks include one out of the box.  But digging deeper into the subject, ORMs do vary from each other, and some cases, very significantly.

Most variations are coming from two main approaches: Active Record and Data Mapper.  I’ve heard the terms for a long time, but today decided to look into the meaning and the actual difference.

The two approaches seem very similar.  The difference is described in a multitude of articles online.  I particularly liked this one.  In essence, Active Record is a better choice for simpler, CRUD-based applications.  Data Mapper, on the other hand, is better for domain-specific applications, as it provides another level of abstraction between the domain objects and the persistence layer.

Most of my work these days is done with CakePHP framework, which I now thought uses the Active Record pattern.  But it turns out that CakePHP ORM so powerful, because it’s more than just one of those:

The CakePHP ORM borrows ideas and concepts from both ActiveRecord and Datamapper patterns. It aims to create a hybrid implementation that combines aspects of both patterns to create a fast, simple to use ORM.

It looks like I need to do some learning and dig deeper into the subject.  Pointers are welcome.

Kazakhstan Is Changing Its Alphabet From Cyrillic To Latin-Based Style Favored By the West

If you think you’ve ever been involved in a huge and complex project, think again.  Slashdot runs the story: Kazakhstan Is Changing Its Alphabet From Cyrillic To Latin-Based Style Favored By the West.

This is a huge change in many regards – technical, cultural, social, etc.  Trying to remember when was the last time I heard about a project of this magnitude, September 3rd of 1967 in Sweden comes to mind.  That’s when the country switched from driving on the left-hand side of the road to driving on the right-hand side of the road.  An icon photograph depicting the change is this one:

And that’s still easier and simpler than the alphabet change, I think.

git clean – a nice addition to git reset

Anybody working with git is probably well familiar with the way to undo the non-committed changes:

git reset --hard

As useful as the above command is, it still leaves some room for improvement. The above command will only undo non-committed changes on the files that git is tracking. Often, this would leave a whole bunch of files and directories in place, which are not tracked by git. So far, I’ve been using a really complicated approach for removing them, which involves git status, grep, cut, xargs, and rm. Yuck.

Turns out there is a better way, which I found in “Stupid git tricks” article:

git clean -df .

This one will forcefully remove all untracked files and directories from the current directory. Combining these two commands together results in all non-committed changes being undone, no matter if they are on tracked files or not. Cool!

How to build a minimum viable product (MVP)

I came across this somewhere on the interwebs.  Which also reminded me of this article (in Russian), which discusses the “progressive JPEG” approach to projects.  The idea being for a project to always be 100% ready, but with varying degree of details being worked through.