Ruby on Rails, CakePHP, MVC Models and Angel Food Cake

Easter evening nerdscape has turned to installing a Ruby on Rails environment onto the WinXP laptop.

What is Ruby on Rails? Ruby on Rails (history) is a software language and environment built for fast and easy programming. Sites like Twitter, Basecamp and others use RoR to quickly rollout web applications in a methodology called ‘agile programming.’ I’ve been reading up on RoR ever since I first heard about it and was compelled to get my feet wet.

The Big Deal About Ruby on Rails: You know how any time you begin anything there are a ton of decisions to make? The strength of RoR is that it has made a bunch of decisions for you already – some programmers find this contraining, others like being able to quantum leap through several hours of application design.

Translation: RoR is a relatively new environment that started off as a sexed-up well-marketed way to program and is gaining traction with developers all over the world who are creating stuff for the web.

The biggest mindmeld involved so far has been getting familiar with the MVC model (or ‘design pattern’ which really just means ‘a way of doing something in a certain way’ or ‘a convention’. This is the overall metaphor that the RoR works in.

MVC stands for Model-View-Controller. I read many different descriptions of this in several books and on several sites. The gist is that the data of the application is separated from the actual handling of the data and that is separated from how it is displayed to the end user.

Here’s how I think about it:

Think of your data – whatever your application is counting, tracking or recording – as ingredients in a cake.

Imagine that whenever your customers (the end user) asks for data, whether it is a list of classified ads or updating a particular shopping cart order or whatever – that you have these bakers who assemble the cake ingredients and bake it up.

Now once the bakers (the Controllers) go to the pantry and get the ingredients (the data Model) and then assemble them as requested, they have to put them in the right type of cake pan – might be a loaf or a bundt – who knows. The cake pan is the View – the different ways users can see, search, edit and create the data.

The Controllers/bakers go get the Model/ingredients out of the pantry (database?) and then cook them up into the View/cake-pan requested.

The most confusing part of learning this for me was that Model refers to the data in the application – not just the tables but also how they all relate to eachother and the particular constraints therein.

A second way to think about this is to imagine the Model/data as clay and the Controllers/sculptors mold it into the View/sculpture.

Why this is a good thing: When you keep these three parts of an application separated, you can revise and update quicker and easier. The RoR environment also includes a ton of extra goodies to plug right into fancy tech like CSS, JavaScript and Ajax.

What is CakePHP: Ever since the MVC way of doing things has become popular, programmers of older languages have started creating frameworks for their languages – in this case PHP. CakePHP uses the MVC model but within the PHP language. CakePHP is still being developed out but has already produced several nice applications online. I’m sorta bouncing back and forth between Ruby on Rails and CakePHP now (RoR has more mature documentation for now).

I’m currently working some coders in India on a new application and we went the route of PHP – we aren’t using CakePHP since they weren’t familiar with it and I didn’t opt for Ruby on Rails because I’d read my host had had problems with developers using it for high-volume applications

Currently I’m reading Rails Solutions: Ruby on Rails Made Easy as well as Agile Web Development with Ruby on Rails.

This entry was posted in General on by .

About Andy Wibbels

Andy is an award-winning blogger and author of the book Blogwild! A Guide for Small Business Blogging. His work has been featured in The Wall Street Journal, USA Today, Entrepreneur, Wired, Business Week, Forbes, and other national and international media. He was worked at several San Francisco startups including Get Satisfaction, SAY Media, InMobi, Keas, and Mindjet. Currently, Andy is Director of Marketing at Lucidworks. Tw · Fb · G+ · Li

One thought on “Ruby on Rails, CakePHP, MVC Models and Angel Food Cake

  1. Susan Bratton

    Thanks for covering RoR – great analogy. We are working on a CMS for Personal Life Media and I’m trying to keep up with the engineering team on this.
    Helpful!
    Do more, please, Mr. Andy.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *