My New MVC Metaphor: The Command Line
11/16/2009 04:53:40 PM
A useful metaphor for the MVC pattern struck me today: The command
line. A command line prompt gives you all the elements of an MVC
architecture.
The Models
On the command line,
the model elements are the programs you execute. ls, grep, awk, cat,
wget, etc... all of those wonderful tools that actually get things done.
The Controllers
The controller elements are the
things you use to tie the models together. The pipes, the redirects,
the ampersands. All of these things allow you to tie models together in
an infinite number of different combinations to do what you want. The
proportion of models to controllers in any given system (or command) is
high. You want it to be mostly models with a little controller
glue...but without the controllers, the models are nearly useless. The
result of all of this, then, is:
The View
Standard Out. Of course, the command line only really has one native input/output format: text. But oh what a format it is.
And the last component...
There's one more component we haven't addressed in this equation, but I'll leave that as an exercise to the reader.