In The Ghetto
Well the world turns
And a hungry little boy with a runny nose
Plays in the street as the cold wind blows
In the ghetto
– “In The Ghetto”, Elvis Presley, Nick Cave, Cartman from South Park, and others…
One of the (many) dirty little secrets of web design and development is the degree of ‘ghetto’ involved. Web technologies, and indeed the Internet, developed in an ad hoc manner, off-the-cuff, usually in a distributed environment with many contributors working on any given technology. It evolved incrementally. In the early days of the web, when developers were still learning the various technologies, what mattered most was just getting it to work — getting info from A to C, via B.
And, in many cases, for many applications, this was alright. For a mom-and-pop shop that needs a Home, About and Contact page, it doesn’t really matter how ghetto your code is. It’s hardly a dynamic application, and it probably won’t overload the server, unless for some strange reason it gets Dugg. If you’re doing sites for mom-and-pop shops, this is still alright, in that the site will ‘work’ and you can get away with a lot of poor practices. Even if the site goes down, it’s probably a server load issue, not your code.
But the landscape has changed. The web development market is looking for more web application development, and rich content, and, as always, the latest and greatest technologies. Web applications can, and do, benefit from the network effect and virality. You might write some little app and then the next thing you know, thousands of people are signing up for it and all sorts of things are breaking — and not just from server overload, but from database load, or weird edge cases, or whatever. It’s your code, dude. Now, as the site owner, you need to fix certain things. Quite possibly, your developer is long gone, and even if you can track her down, she might not want to work on your site anymore. And even if she does, she might have problems debugging the issues, because her code is ghetto.
The main lesson I’ve learned is: for any given piece of functionality, it usually only takes a few lines of code to accomplish the base-level, proof-of-concept effect, but your solution will not be robust unless you make it so. And robustness is where all the extra work comes in. It means using an MVC framework, for web development. It means wrapping your functionality with interface layers. It means abstraction and genericization. Ghetto code is not generic, or genericised, and that’s one of the main things that makes it ghetto. There are a lot of other ways to make your code ghetto, if that’s what you’re looking to do. You can make your functions do multiple things, instead of just one thing. You can make your variable names really unilluminating.
