Archive for April, 2008

Wherein I Question the Usefulness of MVC

I decided to use CodeIgniter for a PHP project that I’m working on. CodeIgniter is an MVC framework, not too unlike CakePHP. At least I imagine they’re very similar, but I can’t say for sure as the reason I chose CodeIgniter over CakePHP was that the CakePHP documentation is a mess and I didn’t have time to wade through it. CodeIgniter has been fairly easy to work with so far. I’m sure there are tons of CodeIngiter reviews by developers like me out there, so I won’t bore you with that just yet (future post!).

This post is about Model-View-Controller (MVC) architecture. Like any developer, I’ve read countless retellings of why patterns and MVC are good for your code. True to form, I think those claims are overblown. I’ve worked with people that do everything “By the Book” and I’ve worked with people that hack everything together as best they can. Seeing both sides of it I honestly can’t say that one made my life any better than the other. Unstructured code, if kept reigned in to some degree, can be incredibly flexible and allow you to be agile in the face of rapidly-changing priorities.

For instance, I’m not above having SQL statements in a JSP file. I don’t love it. I try to avoid it if it’s going to get messy. But I don’t think it’s something to be embarrassed about. I can’t tell you how many times I’ve been able to move a change out in minutes rather than weeks because I was able to tweak a query in the JSP. No, it’s not “By the Book”. But it works, and in the end that’s what you get paid for.

My general rule of thumb is that the closer to the end user your code is the more flexible it has to be. Consider the following range of technologies that flow from the user end to the server side: HTML/CSS, Javascript, PHP/Java/Ruby, PL/SQL, database schema. HTML needs to be more flexible than Java, which needs to be more flexible than the database schema. So for every 1000 times you tweak your HTML or CSS, you might need to make a couple of changes to your backend Java. Sounds reasonable.

So coming back to MVC, one thing I’ve never understood is why the controller is responsible for selecting which view is invoked. This seems fundamentally flawed to me. In a language like Java the controller is a servlet compiled into a jar file somewhere. To change the behavior of that file you have to go through an entire release process: change code, test, promote to QA, test, promote to production, test. At MLB, a change like that took about 2 weeks from start to finish. (Obviously the situation is a little different if you use PHP, which is why I’ve decided to use an MVC framework for the PHP project).

In essence, it’s like the backend developers are saying “Move aside HTML, let the big boys make the call. We know better which file should be displayed”. You know what, they don’t and they shouldn’t. Yes, I know about Front Controllers. Yawn. Yes, I know you could easily write the system such that the flow through the views is configured using XML so it can be changed on the fly, as they did at MLB. Snore. Don’t get me started on XML for configuration. These are all solutions in search of a problem. These things can be done, but no one has really ever convinced me that they need to be done. Agility requires simplicity. Simplicity can’t be configured with XML.


Where Go Older Developers?

It seems like a long since I was the youngest guy in the office. Those days were pretty golden. The young turk is the one that everyone lives vicariously through. I remember recounting stupid drinking stories to a cube-full of older developers eager to relive their own youthful transgressions. The young turk can make mistakes that older guys would get reamed for. And he can get away with unsavory behavior because his unofficial responsibilities include comic relief. The young turk has it pretty good.

These days, I’m almost always one of the oldest guys on the team. At R/GA there are some team members about my age, give or take a year, but most of them are between 4 and 10 years younger. Of course, no one would be stupid enough to be caught arguing that age should imply much in terms of ability. The point is that I’ve spent a lot of time in the past couple of years wondering where all the old developers go. At R/GA there can’t be more than 5 developers (including the front-end guys) 35 and older. This is in a company with probably 150 or more tech people. At MLB I’d bet most of the tech group was under 32. With the exception of the CTO, I can’t think of anyone who would have been older than about 38. This is out of about 100 tech people. I have this fear that I’m going to just start melting away when I turn 38. Or worse – be forced to move into human resources. I mean, I know coding is a young man’s game, but this is absurd.

I suppose some become middle management, but since an organization might only need 1 or 2 managers for every 10 developers there are fewer of these to be found too. Lately I’ve been wondering if the older folk need something more stable and find themselves moving to investment banks. I can’t really say because I’ve avoided those kinds of jobs my whole career. Maybe they freelance, or start their own companies. Maybe they get fed up and go teach. Damned if I know. All I know is that it’s starting to freak me out a bit. How much longer until the developer police show up at my door and take me out to the shooting range? Come to think of it I’ve been hearing voices coming from my O’Reilly books – what if they’re really made out of ground-up developer parts? It’s starting to make a certain bit of sense.