| writing that puts story first

Filed Under: design
Tagged As: , , , ,

MVC, Model-View-Controller is a design practice theory that, according to Wikipedia, was pioneered by one Trygve Reenskaug in 1979 as method for developing object-oriented in a smart fashion. How smart? The development of any project is broken down into three separate areas, each of which can independently be changed without affecting any of the others.

Simple right?

Simple right?

Modelto put it bluntly, this is the raw data. For many websites, this is your database, the raw or stored data that is to be rendered into usable presentable content by the website. See updated section below

View – as the name suggests, this is the outward looking portion of a website or application, typically, this is the graphic user interface (GUI). Many developers are loathe to admit this, but the “pretty” is often how people judge an application.

Controllerthe final, and arguably the most important part of the trifecta that is MVC, the controller aspect is what makes the application actually work. See updated section below.

MVC has recently come back into popularity in a major way due to two main things. First, would be OSX. When Jobs decided to scrap OS9 and all prior work, and instead borrow from the OpenSource community and his work at NeXT, it was determined that OSX would basically force programmers to use the MVC pattern when developing software. This was largely to allow OSX to dictate the View section, thus assuring a standard look and feel through all software running on Macs.

The other is the internet darling that is Ruby-on-Rails. RoR is, of course, everywhere based largely on the ease with which new programs can be made. Case in point is typically Twitter, which was purportedly built from spec in less than two weeks. While RoR doesn’t have any special abilities (that I’ve seen in my limited developers knowledge), because it forces developers to use MVC, mistakes which would ordinarily weigh down a development process are severely reduced.

Why take all this time to delve into the details of MVC? Because I’m firmly in the V category. Even though I’ve been building websites for several years now I’ve restricted my work to two main areas – designing static websites through a combination of CSS and X/HTML and templating various OpenSource packages (mainly Wordpress and Joomla).

Just as I got into designing webpages because the built in blogspot templates didn’t satisfy how I wanted to present myself online, I am now in a position where the content management systems I use (Wordpress for this site) isn’t adequate in it’s current form. Yes, Wordpress is very extensible through third party plugins. The downside is that these plugins often don’t do exactly what is required or do more than needed. So, just as I did when I started learning basic design skills so many years ago, the V if you will, I’m now moving comfortably towards the C.

First up is the language of the software that I most frequently work in, PHP, and by extension, becoming more familiar with MySQL databases (that’s the M, for those keeping score). Why? In the end, it pays to be the entire product cycle when you’re working for yourself. Or to put it more bluntly, I’ll be more of an internet badass.

Update

Got a nice block of instructrion from aut0poietic which corrected some of the over generalizations I used in the definitions for Model and Controller. Here are more correct definitions:

Model: The model is not just the database, it’s the Data Access Layer. It’s typically an Object (capital O) that has been built expose a generalized API specific to the Application. A Wordpress Model Object would have an API with methods like “getPost()”. getPost would return a Post Object that encapsulates the data.

Controller - It’s basically a traffic cop — directing messages back and forth. In a true MVC application, the Controller is painfully stupid: It does little more than send messages to the View when the Model updates, and the Model with the View updates. What it does contain is business logic, so that it sends the correct message, with the correct information based on business decisions.

And on why Wordpress is not a true MVC pattern: Template files should be View, but instead it’s a mash of view and controller. The Loop *should not* exist in the View. The view should not reach out to the Model and get data, nor should it submit data.

Filed Under: technology
Tagged As: , ,

Thought I had lost the databases for not only this, but also the subter.com. Both sites were throwing a “error connecting to database” message. My first thought was to check the status message displayed on my host’s webpage and I noticed that two different file server clusters were having “issues” recently and figured that my problems were probably related to that.

They weren’t.

I waited a bit, hoping the problem would resolve itself. It didn’t. I sent in a support ticket, which is usually enough to get any issue resolved with my hosts. I received no response. I came into work this morning and saw that both this site and subter were both still down and I had yet to hear back from my hosts. So, I figured, I worked tech support at a web hosting company for several months, I’m a fairly competent guy, I’ll do it myself.

The first thing you learn when working tech support is that the vast majority of mistakes are user error. The acronym frequently thrown around is PEBKAC (Problem Exists Between Keyboard and Chair), and you can usually diagnose the PEBKAC calls within the first 15 seconds of the conversation.

If you know, you know.

If you know, you know.

I sat down and started thinking about everything that I’d done server-side recently, to try and determine what I possibly could have screwed up. The only thing that came to mind was that I had recently removed a website that I’d been hosting for some other people. Turns out, the database server was lumped under that name.

My first fear was that in using the auto removal tool for that website, I had taken out not only the database for this site (no big loss, not much here) but also the database for subter (which has quite a bit of quality writing on it). I jumped into the database server and lo, the databases were still there. It wasn’t my fault, or so it seemed.

I started banging out a rather angry email to my hosts about how a pair of my websites had been offline for close to 60 hours now when I started thinking about DNS. You see, I started this saying at the hosting company I worked for, “DNS is magic.” The saying stuck because, for all intents and purposes, it is. The process is completely transparent to not only the end user, but frequently the users in the middle. I realized that the hostname for my sites’ respective databases included the domain name that I had recently stopped hosting. Common sense snuck in – if I were a host, and someone stopped hosting a domain with me, I’d strip that domain name from the local DNS system instantly.

I found a second database hostname for my websites, chanced them out in the CMS’s configuration file and a chorus of angels opened up above.

The sites were saved…and then the squirrels attacked.