« The ten year bug hunt | Main | Support Ticket Prayer »
Monday, November 22, 2004
Why 12 months is too long and procedural code is just wrong
Writing internet software is always a roller coaster ride. I often look at 'desktop' application developers with envy. They have the luxury of a relatively stable operating system which can go many years without any major developments which could make their code redundant. They also can write for a specific operating system, whether it's Windows, OS X or Linux, they know they only have to target one specific operating system. I'm sure that application developers view internet developers with envy, but you'll have to visit their blogs for that insight.
Internet scripters don't have those luxuries. We have to write portable code that has to run on a handful of different operating systems that all bring their own development problems. (Side note: Who at Microsoft thought that using the escape character, the backslash, as a path separator was a good idea? I'd like to meet him and see if I can get some money back on therapy required after running the stripslashes mine field). We also have to use a series of ever-changing scripting tools such as PHP or perl tied into databases with frequent and code-breaking changes. This creates a very unstable development environment.
This brings us to the title of this prose: twelve months developing a product for the internet is too long. Many things change on a daily basis and you can never assume that the development platform you're using to write your code is still going to be valid by the time you've finished the initial code base or rewrite. I learned this the hard way.
Learning the hard way
In a previous life, I developed and maintained a perl project. This project got to the point where it was obvious that a rewrite was required. The architecture was struggling under the weight of bug fixes, hacked in features and code limitations. I had taken a basic and badly designed code base as far as I could. I was conversant in perl and didn't really want to switch to another language. This was back in those dark days when perl 6 was lauded as "right around the corner" and PHP had triumphantly released PHP 3 and development of PHP 4 started. PHP 3 was a weak language with too many restrictions and work arounds needed to manage a project the size of the one I was managing. It wasn't a hard decision to continue writing perl. Perl 6 was on the horizon so it made sense to ditch procedural code and work entirely in OOP (object orientated programming). I created a lavish frame work with a modules and class system. I figured that when perl 6 was picked up and used on our customers' servers I could simply rewrite these modules independently without affecting the framework. I also wrote an intricate database abstraction class which could load sub-classes to process a query set I developed which meant that if a database engine changed, I could rewrite the sub-class without needing to touch a single other file.
The theory was sound, no doubt about it. Unfortunately this took nearly 18 months to complete. I went over deadline by a spectacular 6 months and was forced into releasing a product which I knew wasn't complete or anywhere near bug free. To complete the project properly could have taken well over two years. We upset a lot of our customers with repeatedly missed deadlines and while we were rewriting our code, the web hosting industry moved from perl to PHP 4 and perl 6 became more of a pipe dream than a reality. After 18 months of hard development all I was left with was a brilliant theory, outdated code and unhappy customers.
Lesson learned
This mistake was still very raw when I began the foundations of a new product. It was obvious that it couldn't take too long to release the first version and the experience helped me form a development roadmap. This time around, I'd develop the framework with the same ideals but introduce a smaller feature set. These features could be introduced over time with quicker version releases.
OOP was an obvious choice for this new project. A lighter, more manageable database abstraction engine was created to handle changes to relational database engines and a class structure was employed to cover the basics such as emailing, printing output, template handling, etc. Modules were introduced to handle different information requests. All of these objects can quickly be rewritten without changing any other code.
Procedural code is simply too hard to manage when a project reaches a certain size. The need to bug fix, maintain and introduce new features creates a mess of code which runs out of control. The architecture is hardcoded into each file which makes the system inflexible. A rewrite is inevitable and just a matter of time and it'll take a good deal longer to rewrite procedural code, which is time badly invested.
I recently released a major version increment which introduced many new features and a fresh interface. I'm still using the framework I devised nearly three years ago. Nearly every module and class has undergone some surgery to introduce new features and to maintain the project but I was able to approach each module as an independent part of the greater program. I was able to turn around a major release in a little over 6 months and without needing to rewrite every line of code. I couldn't do this with the procedural code I had previously developed.
The moral of the story
The moral of the story is very simple. Don't ever bite off more than you can chew and the first release doesn't have to be the last release. Plan your development wisely and aim to release frequent updates to achieve the feature set you originally had in mind. Use OOP where you can and always keep in mind that the code you're writing will need to be maintained and eventually rewritten. Invest your time well and you'll never have to apologise for missing your own deadline by six months.
Oh, and if you're writing an operating system, never use the backslash character for anything important. It's for escaping characters and nothing else.
November 22, 2004 | Permalink
TrackBack
TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83423035953ef00d8345f824469e2
Listed below are links to weblogs that reference Why 12 months is too long and procedural code is just wrong:
» Find search engines across the world with Search Engine Colossus from Meta-Search
Gain quick, efficient access to search engines from countries around the world with Search Engine Colossus - International Directory of Search Engines... [Read More]
Tracked on May 22, 2006 2:46:00 AM
Comments
Thats a huge risk when developing anything. Do you either put tons of time in and release a full stable release. And risk it being outdated when eventually released. Or develop in smaller chunks and continuously update based on new technology.
Either way never set deadlines.
Posted by: Wilko | Nov 22, 2004 1:58:20 PM
Deadlines and death are two certainties in life. You have to set deadlines or you'll never make a release, ever.
I constantly battle with myself because as the project manager I want to hit hard and fast deadlines to wow the customers and as the lead developer I want to write beautiful and bug free code and not worry about release dates.
Posted by: Matt | Nov 22, 2004 3:08:51 PM
Furthermore:
This will probably result in this entry being taken off course and an argument resulting from this comment, but here it goes:
Look at phpBB 2.2. It's been in development for literally years (in terms of the project being announced) and it's already looking dated. I'd imagine the team are having to tweak already written code to work with PHP 5 and MySQL 4.1 because if they don't it's instantly outdated. The features set is out of date and compares with vB2 and IPB 1.3.
Paul and co. do a great job with phpBB and I'm painfully aware that developing a product in your spare time without funding is a largely thankless task but the fact still remains it's taken far too long and is already looking dated because the rest of the world as moved on since they started development.
Posted by: Matt | Nov 22, 2004 3:12:02 PM
I must say that deadlines are a good thing if you can have strict deadlines that you stick to, that aren't too far apart and have different stages in the deadlines. Thats one great thing about the gnome project they clearly set deadlines of different aspects for their desktop environment. I personally think they should double all their times (make it a yearly release rather then 6 months as its a huge project and not that much changes in 6 months and leaves more room for it to be unstable)... but I think their release timeline is great for web projects.
Setting a feature freeze a couple weeks prior to the first beta (and sticking to it, not even adding the smallest little feature) and a UI (skin freeze) at the time of the first beta (other then to fix bugs obviously, but no reworking stuff for the hell of it) is important to making sure you have deadlines and release good quality, highly stable products. Feature-based releases are the devil (don't feel like working on a certain feature and work on a million others before writing a certain feature prior to the release) along with setting deadlines is the devil, time-based releases aren't. I've learned that promising features prior to their writing is the evil part, not the deadlines.
Posted by: aent | Nov 22, 2004 5:11:48 PM
Ok, I suppose deadlines are important. What I meant to say is don't set deadlines to customers.
It only gives them false hopes and if you can't produce they often complain. Setting yourself deadlines to finish project are always good as it increases productivity in the sense you have something to work towards. I was wrong in my above post :(
Posted by: Wilko | Nov 23, 2004 10:06:05 PM
Regarding OO vs. procedural. I agree that properly written object-oriented code can be easier to maintain and extend, but I would take badly written prodecural code over badly written OO code any time. Simply using classes as a means of wrapping functionality is pretty much useless. Object-oriented programming becomes useful when you start to utilize all of it's benefits. OO is not just setting up a bunch of classes with methods and attributes, it's inheritance, encapsulation, abstraction, polymorphism, code re-use, overriding of methods etc, etc. You can realize some of these "features" in PHP4, but sadly, a lot of the benefits of OO programming are lost when working in PHP4. PHP5 has made the situation better, mainly by allowing proper encapsulation, but there's still a long way to go. What's my point? Use OO not because you can, use it because you understand the benefits and know it will improve your code.
Posted by: Rickard Andersson | Nov 26, 2004 12:18:56 AM
Posted by: | Dec 13, 2004 11:54:26 PM