600 Line Design

Jeff Atwood recently posted the question What Can You Build in 600 Lines of Code? He points to the fact 37signals went live with Ta-da Lists which had only 579 lines of source. In actual fact this is not quite as magical as it seems, as Jeff goes on to say:

“They actually built the entire Rails framework first to support building small apps like Ta-da Lists. None of the required Rails framework code, nor any of the necessary stylesheets, JavaScript, HTML, and so forth, are included in that number.”

This got me thinking “Isn’t that a great way to design your software architecture?” If you can’t write your app in less than 600 lines of code then build separate supporting modules with clean and loosely-coupled interfaces so that you can. And if any of those modules require more than 600 lines repeat the process as necessary.

Of course for this to be a meaningful approach you can’t just cut code out of one source file and paste it into an include file. You have to design your modules so that they have minimal dependencies and provide functionality that is as generic as possible. Kind of like writing a mini-framework just for your application.

With this thought in mind I re-read Derek Sivers post 7 Reasons I Switched Back to PHP After 2 Years on Rails (which I first linked to in my 2007 September Web Roundup). Suddenly it seems clear that he applied the Rails model of a re-usable framework to his PHP coding and shaved 90,000 lines down to 12,000 (including all HTML templates).

Advertisements

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: