When to roll your own software

If you're ever wondering whether to roll your own software, use a framework, or use an existing content management system, CMS, for a project or to learn, here's the advice I give everybody.

Roll your own, then adopt an existing framework or CMS so you don't have to worry about everything you don't know you don't know.

This is actually a very common topic I've run into when working on large projects. I'd bounce the idea off other seniors, and we're pretty much all in agreement with it. If someone wants to learn, have them write a framework, then a CMS on top of that framework. They'll quickly realize problems such as short-sightedness on design, incorrect estimation of the time, and most importantly, finding out what they didn't know prior to starting. It's an extremely insightful task to undertake, and I recommend anyone trying to learn to do it.

Writing your own framework has you working directly with php (or whatever language you choose to use) without bumpers. Nobody's holding your hand, and you'll get bit. If you spend enough time on it and see the project's size grow, whether actually in production or not, you'll start realizing your mistakes and come to an understanding with why framework developers make design decisions like using an MVC pattern. Conversely, you'll find projects out there you thought were good, but are completely asinine when looked at with your new found insight.

The reason I say to write a CMS on top of your framework is to put your framework through a stress test. You never fully understand the complexity of something you write until you actually use it. Bugs will be found everywhere, even in places you didn't think would affect something. You might find out, as I have before, that you made a fatal mistake in your design from the very start, but didn't know it was a mistake at the time. I wound up abandoning one of mine after too many design flaws were found that required fixes of exponential size and complexity, but this wasn't bad. You learn from these things, and progress.

After a couple frameworks in production, I decided to write one based on what I knew and learned. My coworkers liked it, and I really liked how it was feeling. I stopped working on it when I found Zend Framework was first released and realized I was basically writing the same thing, so I stopped and started using that instead. As an aside, the same thing happened to me with jQuery when it was released as I was trying to write a script.aculo.us alternative; use what's out there and accepted if you agree with it.

When you understand the decisions made for projects, you'll understand which fits your tastes better. If you understand a project, then you can customize it, write plugins and modules, fix bugs, and grow. You don't have to be an expert on everything you use, but if you can understand where something may fail and are able to dig through the code to understand where you might be going wrong or misunderstanding, then that's where you need to be.

If you develop enough software, you do things many times over and over like scaffolding, basic security, and data sanitation. If you keep doing them time and time again, you'll make a mistake once in a while, so do it once and reuse it. This is where a framework comes into play. The framework takes the repetitiveness out of the equation so there are fewer points of failure for any single project.

Software estimation is what should be used for deciding to either roll your own, roll it on a framework, or use an existing CMS. If it's a small project that may just need a simple script to run, say as a cron to process database logs, you might be best to roll your own without a framework. When the scale grows, then you need to weigh custom software on a framework against a CMS. Figure out how niche the system needs to be, and how much customization of a CMS would be required. Then compare that to the resources required to write it from scratch. Most of the time, you'll find that modifying a CMS is the best solution, but there are times where rolling your own should be done instead. Common things like blogs, forums, stores, articles, newspapers, social networks, and wikis should be grabbed off the shelf and modified. If you're doing something like reservation software, medical records requiring specific government-imposed storage regulations, online games, or anything you can't seem to be able to do by molding an existing CMS, then roll your own.

Copyright © 2004-2022 MecroMace LLC