Model View Controller

© 2003-2012 James Dempsey

MVC’s a paradigm for factoring your code,
Into functional segments, so your brain does not explode.
To achieve reusability, you’ve got to keep those boundaries clean,
Model on the one side, view on the other, the controller’s in between.

Model View
Yeah, it’s got three layers like them Oreos do
Model View Creamy Controller

Model objects represent your application’s raison d’être
Custom objects that contain data, logic, and et cetera
You create custom classes in your app’s problem domain
Then you can choose to reuse them with other views
But the model objects stay the same

You can model a throttle and a manifold
Model the toddle of a two year old
Model a bottle of fine chardonnay
Model all the glottal stops people say
Model the coddling of boiling eggs
You can model the waddle in Hexley’s legs

Model View
You can model all the models that pose for GQ
Model View Controller

View object tend to be controls used to display and edit
Cocoa’s got a lot of those, well written, to its credit
Take a Cocoa text view, hand it any old Unicode string
The user can interact with it
It can hold most anything

Oh but the view don’t know about the model
That string could be a phone number or the works of Aristotle
Keep the coupling loose
And so achieve a massive level of reuse

Model View
Yeah on a retina display y’know it’s all times two
Model View Controller

I’ll bet you’re wondering now
I’ll bet you’re wondering how
Data flows between model and view
The controller has to mediate
Between each layer’s changing state
To synchronize the data of the two
It pulls and pushes every changed value.


Model View
Mad props to the SmallTalk crew
For Model View Controller

Model View
It’s pronounced ‘oh-oh’, not ‘ooh-ooh’
Model View Controller

Controllers know the model and view very intimately
They gotta know just enough to do all the right stuff in this ménage à three
They’ve got a lot on their plate, also need to integrate OS functionality
In their coordinating role
They give your app its soul
Making it all that it can be

Model View
Notification, delegation, target action too
Model View Controller

Model View
Model View
Model View Controller

Model View
Now you can claim to be an MVC guru
Model View Controller

This version of Model View Controller debuted at the first James Dempsey and the Breakpoints LIVE near WWDC show on June 13th, 2012. The song was updated from its original version with a few tweaks and a more general verse about controllers—the original 2003 lyrics focused on the then newly-introduced Cocoa Bindings. The track Model View Controller (Legacy Mix) contains the original lyrics in their entirety.

( OS X / iOS )

Vocals: James Dempsey
Guitar: Gordie Freedman
Bass: Darren Minifie
Slide-Advance Keyboard: Victor Alexander
Drums and Organ: Russell Bond

Music and Lyrics: James Dempsey
Recorded and Produced by Russell Bond at HowlingPoint Studios