My Secret Life as a Spaghetti Coder
home | about | contact | privacy statement
This morning I was going through some code that my team and I wrote a couple of weeks ago. We had violated DRY in an attempt to show a client (who wanted to show a venture capitalist) our progress (sort of by faking it, I guess). It seemed necessary at the time (and I still think it was), and it worked fine.

In any case, I promised myself that before this iteration was over, I would refactor the code, because I didn't want it to become a nightmare to maintain. I started out trying to get the whole thing in one go. When I was almost done, I suddenly noticed "there's no way this is going to work." I had removed some code that was needed for another piece to work, and couldn't remember what the code was - I just noticed it was missing.

It was Javascript as well, so it's not like it would have been incredibly easy to figure out what the problems were, had I continued along my path.

Anyway, I started over, taking baby steps - one small bit at a time, while ensuring what existed still worked. It helped a bunch.

So, the lesson is: As while coding in general, it is important to take baby steps when refactoring.

Hey! Why don't you make your life easier and subscribe to the full post or short blurb RSS feed? I'm so confident you'll love my smelly pasta plate wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!


Comments
Leave a comment

I do the opposite! Get a big knife and hack that cancerous code clean out.

Ok, maybe it's not that extreme, but I do like to see huge stonking errors and not subtle ones as I refactor.

Posted by Adrian Lynch on Dec 25, 2007 at 01:56 PM UTC - 6 hrs

Ack! That sounds like rewriting. =)

The small steps don't typically have errors more subtle than your normal ones. The point of taking the baby steps is that you make one small change, then ensure it still works.

If it doesn't, fix it until it does.

By taking the larger step before testing, when it breaks, you can't be sure where - just somewhere in that big knife cut. That's why I feel it is more like a rewrite - which of course is an acceptable solution to many problems.

Posted by Sammy Larbi on Dec 27, 2007 at 10:19 AM UTC - 6 hrs

You've read The Pragmatic Programmer haven't you? :OD

I see you point. I don't think I've got my terms nailed down.

Posted by Adrian Lynch on Dec 27, 2007 at 03:46 PM UTC - 6 hrs

No, but it is on my desk in queue waiting to be read =).

I have read several related things though, and Refactoring is on my list and desk as well. I hope to devote a bit more time for (non-school-related) reading in the new year though. =)

Posted by Sammy Larbi on Dec 27, 2007 at 04:06 PM UTC - 6 hrs

Oh definitely make time for PP!

My two favourite work related books - The Pragmatic Programmer and Hackers & Painters.

http://www.adrianlynch.co.uk/books.cfm

I've read them both more than once.

Posted by Adrian Lynch on Dec 27, 2007 at 05:00 PM UTC - 6 hrs

Leave a comment

Leave this field empty
Your Name
Email (not displayed, more info?)
Website

Comment:

Subcribe to this comment thread
Remember my details
Google
Web CodeOdor.com

Me
Picture of me

Topics
.NET (19)
AI/Machine Learning (14)
Answers To 100 Interview Questions (10)
Bioinformatics (2)
Business (1)
C and C++ (6)
cfrails (22)
ColdFusion (78)
Customer Relations (15)
Databases (3)
DRY (18)
DSLs (11)
Future Tech (5)
Games (5)
Groovy/Grails (8)
Hardware (1)
IDEs (9)
Java (38)
JavaScript (4)
Linux (2)
Lisp (1)
Mac OS (4)
Management (15)
MediaServerX (1)
Miscellany (75)
OOAD (37)
Productivity (11)
Programming (168)
Programming Quotables (9)
Rails (31)
Ruby (67)
Save Your Job (58)
scriptaGulous (4)
Software Development Process (23)
TDD (41)
TDDing xorblog (6)
Tools (5)
Web Development (7)
Windows (1)
With (1)
YAGNI (10)

Resources
Agile Manifesto & Principles
Principles Of OOD
ColdFusion
CFUnit
Ruby
Ruby on Rails
JUnit



RSS 2.0: Full Post | Short Blurb
Subscribe by email:

Delivered by FeedBurner