Model View Controller Web Development For Drunks

We poppin bottles

It’s 3:35 in the AM on a Saturday night, or what annoying people call “Sunday Morning”.

You just got home from a long night of drinking and you are fucking starving.  Nothing is open, so you’re relying on your remaining brain cells to make something to eat.  You grab the mish-mash of stuff and head onto the stove. Eggs, leftovers, hot sauce, and all the other crap that you thought would be good at the time all goes on the skillet and 3 minutes later you’re eating a Jackson Pollock like concoction on your plate.  It’s not the best thing you’ve ever eaten, but it satisfied the need that you had to satisfy right then and there.

Now, as a man that has once put wasabi as a rub on chicken (which rendered it STRAIGHT UP inedible), I know a little something something about cooking drunk, and a little bit about web development.  If you’re even remotely aware of anything about web development, you’ve probably heard of something called Ruby on Rails (or Rails for short) that’s sweeping the nation.  Ruby on Rails is a framework that allows for the rapid development of web applications using the Ruby programming language.  Basically, it’s a bunch of stuff people wrote in order to save them time from writing it again.  It’s like buying lined paper instead of drawing lines on paper every time you needed lined paper.  Sort of.  I know that wasn’t a cooking reference but get off my back, will ya?

Anyway, being the smartass I am, I decided to turn my back on learning Rails and Ruby on Rails and learn Django – pretty much the same thing except for the programming language Python, which I already sort of knew.  Despite the fact that the documentation for Django is pretty fucking terrible, I think I’ve started to get the hang of the grand concepts of why you’d ever use a Model View Controller framework (which Rails and Django are).

May I present to you my grand metaphor for Model View Controller frameworks:  drunk cooking.

mvc

 

Let me explain.

The Model

In my opinion, Model View Controller development all starts with the model – or what you want the models to become.  A model is just a table of data in a database that the controller can access.  Basically, it’s your fridge.  Everything that you can use to craft your is essentially stored inside of this bad boy.  Just like a piece of chicken can pretty much become anything that tastes like chicken, so too can your data become pretty much anything that tastes like chicken (or whatever useful task you’re trying to accomplish).  You’re basically trying to take separate types of information and trying to combine them in delicious ways, like so:

It's a Doritos Locos Tacos

Fig. A – Combining different things in order to make something awesome. This is the website “Rap Genius” if it was a food item.

 

The Controller

The controller is you.  You’re the person that’s running the ship in this kitchen, so it’s up to you to fucking do something with the stuff that is in your fridge (the model).  Grabbing eggs and cracking them is essentially the same as taking a list of names in your model and sorting them alphabetically.  Squeezing an excessive amount of sriracha into your frying pan is the equivalent of finding all of your data that starts with the letter B and listing them.  I think you get the idea.  You’re taking something and then doing something with it.  Make it fun.

Geoffry from Fresh Prince Swagging Out

Fig B – After assessing the available ingredients, you have to ask the question “turn down for what?”

 

The View

This is what ends up on your skillet/plate.  This is how the thing looks when it’s all cooked together and most likely plopped onto your semi clean Ikea plate that you will then shovel into your drunken face very quickly.  To get a little technical, this is where Django and Rails kind of separate (views in Django are the functions that are built on a combination of the HTML output as well as things like URL mapping, where as apparently in Rails this is only the HTML.  Whatever, we’re drunking cooking here!)  This is the stuff that’s the end product that you see and that you consume.

Jamie Oliver garnishing

Fig C – “Go on en, toss a bit of pucca on ye dish yah? Giv it a bit of pop m8” – What I imagine Jamie Oliver would say about your web app

 

 

 

Hopefully that enlightened you a little bit about the world of programming and web development.  Here’s a couple of resources I recommend if you want to start drunk cooking yourself:

Buzzed

Hammered

Rob Ford

  • Tango With Django – What I’m doing now.  Works off an older version of Django but everything seems to still be very relevant.
  • Two Scoops of Django – From everything I gather, this is the definitive book for doing Django correctly.  Probably my next step.

Leave a Reply