Author: Nathan

Skype Click to Call makes Firefox painfully slow

I’ve been having some troubles with Firefox lately, particularly when trying to use gmail. It’s been painfully slow (10-15 seconds just to change folders), and locking up the whole browser in the process. I decided to finally take my own advice and go through the troubleshooting steps we suggest people use when they’re having similar problems with SearchTempest.com or AutoTempest.com.

I found that if I restarted Firefox in safe mode (with all add-ons disabled), things were once again nice and snappy. Went from 10s+ to switch labels in gmail to around one second. Sweet. At first I figured the culprit must be something gmail-related, like PowerBot or Gmelius. (And I was pretty choked. Losing Gmelius wouldn’t be a big deal, but PowerBot is a huge productivity boost for me.) Fortunately though, the real culprit was an add-on I never use and didn’t even install: Skype Click to Call. It appears that this add-on is installed automatically when you install Skype. It’s probably an opt-in of some sort, and I imagine I must’ve figured it would be useful at the time, but for some reason, they failed to mention how it would make the browser an order of magnitude slower…

Anyway, it’s gone now, and gmail (and everything else) is fast once again!

My new workspace

In case anyone’s interested in a small glimpse into my life, I just finished the little details of setting up my new workspace (just moved a few weeks ago) and figured I’d share.

My Desk

OK, honestly, it’s because it’s the first time I’ve ever done proper cable management. Here’s how it looked before. 🙂 And yes, it’s always that clean now. … Yep. At least, when I take pictures of it, it is. Just don’t pan to the right or left at all. Or down. But otherwise, veeeery tidy.

The desk is a NextDesk Terra, which I don’t love everything about, but the huge surface and sit/stand adjustment are great. Monitors are BenQ BL2710pt, which I do love everything about. Except the OSD I suppose, but you pretty much use that once ever, so I can live with it. 😉 Great review of it here if you’re interested. PC is a Sandy Bridge home build from about three years ago in a Fractal Design Define case, which has been great. (I like things quiet, so probably spent more time picking out the case, fans, and PSU than the primary components…)

Oh, and the kid on the calendar and the Amazon gift thing on the desk is my daughter, Lila. In fact, that one deserves a closeup. 🙂

Christmas Elf

The toys you’d see on the floor if you had panned down before are (mostly) hers too.

And that’s about it! Welcome to my little world.

 

What’s the best way to search craigslist?

*Note that the Tempest Blog and SearchTempest.com are in no way affiliated with or endorsed by craigslist.

Craigslist clearly has a fantastic wealth of classified ads available in every conceivable category. However, their search capabilities are relatively limited. Fortunately, there are a number of useful tools out there to help with searching craigslist. Which one is best really depends on what you’re hoping to find. Here’s our completely biased rundown:

For the Locals

First off, if you’re really just interested in your own city, and you’re not shopping for an apartment or a car, your best bet is probably just to search craigslist directly. (And you’re probably not actually reading this…) In case you are reading though, when searching directly, keep their advanced search syntax options in mind. They can often come in handy, allowing you to combine multiple searches into one.

Globetrotters

On the opposite side of the spectrum, say you want to find something on craigslist, but you don’t care where in the world it is, or what category it’s in. In that case, your best bet is simply to use Google’s ‘site’ operator:

your search terms site:craigslist.org

One downside is that in many countries craigslist uses the country’s own top level domain instead of .org. (For example, craigslist uses .ca in Canada and .co.uk in the UK.) With the query above, Google won’t catch those. Of course, you can add them to your query, like this

your search terms site:craigslist.org OR site:craigslist.ca OR site:craigslist.co.uk

but that quickly becomes tedious if you really want to search everywhere. And of course, this method doesn’t let you narrow your search either; you’re basically stuck with results from (almost) everywhere and from every category, even if you’re only looking for, say, a motorcycle in your home state. That said, it can’t be beat for speed or simplicity.

Power Searchers

One option to have a bit more control over where you’re searching is the tool we came up with: SearchTempest.com. With SearchTempest, you can choose exactly which craigslist cities you want to search, in a couple of different ways. The easiest option is to enter your zip (or postal) code and the distance that you’re willing to travel. However, if you prefer you can also search by state, or even choose specific cities. You can select the category and subcategory to search, as well as only show results since a given date. And finally you can get results from eBay, Amazon, and Oodle (Facebook Marketplace) at the same time (but only if you want them).

Perfectionists

SearchTempest isn’t perfect though (although we certainly try!) Its default mode is powered by Google, so it should offer basically the same results as the Google method, just with a bit more flexibility in terms of where to search. One downside to this though, is that Google does occasionally miss craigslist posts, or at least takes a while to find some. (Most posts are found within minutes, but some take hours or longer to show up, especially in less popular cities and categories.)

If you really want to be sure to catch everything, especially if you’re searching for something obscure, using craigslist directly might be a better option. However, if you still want to check multiple cities, SearchTempest has an alternate mode called Direct Results that we hope offers the best of both worlds.

Basically Direct Results mode allows you to open results pages directly at craigslist.org, but adds a little navigation window to quickly flip through cities. So you’re getting results straight from the source, just as if you’d searched directly, but you save the effort of manually typing your search into each site. It still takes a bit longer than the Google-powered option, but you’re seeing exactly the same results as if you searched each city manually.

Serial Searchers

Now, if you tend to run the same searches repeatedly, you have a couple options to speed up that process. First of all, if you’re only checking a handful of cities, one great technique is simply to bookmark the craigslist results page for each city, and put all the bookmarks in a folder. Then you just use your browser’s option to open all bookmarks in that folder in tabs, and you’ll have the newest results for all the cities in your search.

If you prefer a bit more automation, craigslist supports RSS feeds, which are built for this sort of thing. Each craigslist results page has an orange RSS link, which you can click to add the feed to your reader of choice. (If you don’t have a favorite, we recommend Feedly. No affiliation – we’ve just found it to be the best free option so far.) You can create a folder for each search, and add the results feeds for all the cities you’re interested in. Then just click on that folder to view the new results from all of them in one place. It keeps track of which posts you’ve already seen too, so time is wasted retreading the same ground.

If you’d like to speed up the setup a bit, SearchTempest can help with that too. Just run a search at SearchTempest.com, then click the “Feeds for this search” link at the top-right. It will generate a file that you can import into Feedly (or your reader of choice) with the matching feeds for every city in your search, saving you the effort of adding them one by one.

Car Buffs and Vagabonds

While all the options above will work regardless of what you’re seeking, for some searches there are better alternatives. For apartments, Padmapper is a cool site that will show you results from craigslist and several other sites, all on a map as the name implies. Craigslist has also recently added a map option, but it’s not as slick as Padmapper (yet, anyway), and obviously lacks results from other sites. (We’re not affiliated with Padmapper; I just think it’s cool.)

If you’re looking for a car (or truck, or van…) we’d like to think AutoTempest.com (our other site) is worth a look. It ties into SearchTempest, so you get everything mentioned above, plus it adds results from all the other top car classifieds sites: AutoTrader (no affiliation), Cars.com, CarsDirect, Oodle, eBay Motors, and more. Also, it simplifies things like specifying model years. It is possible to specify a range of years using craigslist’s advanced keyword syntax, like this

1998|1999|2000|2001|2002|2003|2004

but with AutoTempest you don’t have to bother; we do it for you.

In Summary

  • Searching a single city? Just use craigslist.
  • Don’t care where, just want results fast? Google’s site: operator should do the trick.
  • Want to choose where to search? Try SearchTempest.com.
  • Want to get every result? Try RSS feeds if you’re running the same search a lot, or Direct Results mode otherwise.
  • Searching for a car? Try AutoTempest.com. An apartment? Padmapper.

Did I miss anything? Let us know which tools you use to search for classifieds in the comments!

How to make your craigslist For Rent or For Sale post not suck

There are a truly surprising number of really terrible housing for-rent and for-sale ads out there, on craigslist and other sites like it. Don’t make yours one of them! Here are some of the top things to avoid:

Bad Pictures (Or none at all!)

Aside from the title (which should be long and descriptive), the pictures are the first thing people will notice about your posting. Don’t post pictures that suck.

One picture (or two or three) is not enough!

If your ad contains one lonely picture (often of the laundry room or outside or something useless), I’ll pass. If you can, post pictures of every room! And the yard (front and back), plus shots of the exterior and views. But mostly the rooms. If you don’t have a shot of the kitchen, I’m going to assume it looks like this.

Show the house in the best light, literally.

Take pictures in the daytime, preferably on a sunny day. Use a nice camera. If you suck at taking pictures, have a photographer friend do it. If you’re selling your house or it’s an executive rental, hire a photographer to take pictures. Or at least listen to their advice.

Oh, and post the pictures at a decent resolution, and right-side-up for Pete’s sake. If you don’t know how to do that, get someone to help you. Here’s a rule of thumb: if you have to squint to make out the details in your pictures, they suck.

Non-descriptive Descriptions

Don’t post a one-line description! Here’s a post I just read on usedeverywhere.com: “amazing 4 bedroom, 3 bath, large garage great for workshop or storage, large lot”. (It had one picture of what looked like an attic.) That’s not even close to the worst description I’ve read, but even so, it’s one line. If the house is so ‘amazing’, why don’t you tell me something about it?!

Really though, it’s not enough to just tell something about it. You want to tell everything about the house/apartment/shed/whatever-it-is. At a bare minimum, number of bedrooms and bathrooms, square footage, garage size, appliances, yard size, any selling features like air conditioning, pool, recent renos, whatever, and a link to a Google Map of the location. But don’t stop there. Describe the house in detail. Give people enough information to really picture what living in the house would be like! You want them to already be planning who would sleep in what room and how their furniture would be laid out. The better someone can picture living there, the more they will want to live there. (Unless your place itself sucks. But even then, the people who do contact you will be legitimately interested and you won’t be wasting both your time.)

Price Confusion

First of all, state the price for crying out loud. Why do people leave that out? Gah! If you think it’s going to help your bargaining position or something, forget it. You’re losing half your potential buyers/renters right off the bat.

Second, put the price, and only the price, in the price field. If you have two rooms for rent, for $500 and $600, make two separate ads. Do not enter $500600 in the price field. It boggles my mind when people do this. Not only is it annoying, it also removes your ad from pretty much everyone’s search results, since most people are not looking for a five hundred thousand dollar room for rent. Plus, with two ads you get twice the exposure!

Also, don’t put $1 as the price, unless you are selling your house for one dollar. That’s little better than the people who spam a bunch of unrelated keywords at the bottom of their ad. Presumably you realize that if you don’t post a price at all, your ad won’t show up when people specify a maximum. (So you’re one step ahead of $500600 guy…) But you also know the price you’re asking is exorbitant (presumably, or you’d just post the actual price, right?) So you figure you’ll just game the system. Well, don’t. Most likely you won’t be able to rent (sell) your place while still keeping the price a secret, so you might as well spill the beans now. (And if you can’t post the price because you’re trying to list multiple things in one ad, see above.)

Going into Hiding

Be reachable. Put a phone number and an email address in the ad. Include your first name so people know who they’re calling or writing to. You could even write something like, “Feel free to call, text, or email whenever.” You want people to contact you. Make it as easy as possible!

A few more “Don’ts” for Good Measure

Don’t…

  • Write things like “No deadbeats” or “No loud noise after 10” or even “Serious inquiries only” in your ad.
  • Post an ad with nothing but a link to a post somewhere else. If you’re too busy to copy and paste your post, I’m too busy to read it. Linking to more or higher resolution pictures is fine if the site you’re posting on limits you there, of course.
  • Use abbreviations, like “p/m” for “per month”, or “w&d” for “washer and drier”. These aren’t old school newspaper classifieds where you’re paying by the word. Don’t make people decrypt your ad; write it out in plain English.

Summary

And there you have it. Follow those few simple guidelines and at least people won’t be cursing your name as they attempt to decipher your ad or avoid getting eye strain from your photos. That may not rent your apartment or sell your house on its own, but it’s certainly a start.

How to prevent Google hammering server for old linked CSE specifications

Google’s Linked CSE is a fantastic tool. It allows you to dynamically generate a custom search engine for each of your users, or even for each individual visit, based on any parameters available to your application. This functionality has been invaluable for SearchTempest.com as we use custom search engines to provide customized multi-city searches of craigslist (no affiliation).

The problem with this approach is that when you create a Google Custom Search Engine (CSE) with a linked specification file on your server, Google’s “FeedFetcher-Google-CoOp” bot requests that file in order to build the CSE. It then continues to regularly request the file, repeatedly, for at least a matter of months afterward, even if it is never again used by an actual user.

In our case, it got to the point where the majority of all requests for files from our web server were for useless, outdated Google CSE specification files. Unfortunately, once this is happening, it appears there is no way to stop it. The best you can do is to add a rule either the web server or, ideally, the firewall level to block these requests. (Currently we return a 410 ‘gone’ response in as few bytes as possible.)

However, there is a way to avoid getting into this situation in the first place. In short, Google CSE specification files should be served from disposable subdomains. For example, create a subdomain called gcrefs1. For convenience you can point it at the same directory as your main (www) site. In your CSE setup, tell Google to access the file at http://gcrefs1.example.com/filename. Then, after a period of time (once Google’s Feedfetcher bot is making too many requests to the file for your liking), simply create a new subdomain (say, gcrefs2), update your references to point to the new domain, and then remove the DNS entries for the old one.

Of course, it’d be nice if Google’s feedfetcher just respected robots.txt, or reacted properly to 410 responses, but given the usefulness of Custom Search Engines in general, I’ll take what I can get.

Update: It appears that Google ignores 410 responses, but not 301 responses. So by 301 redirecting an outdated cref file to null.html (for example), you should be able to convince them to stop requesting it. (Although the bot will run through each of its saved sets of request arguments one last time, since it sees each as a completely separate file.)

Google not indexing craigslist – SearchTempest switches to Bing

As of February 28, Google has stopped indexing new craigslist posts. Or more specifically, every day between about 5pm and midnight PST, they index them as usual. Then at midnight, they throw them all away. So anyone searching Google for craigslist posts over the past couple weeks has been faced with a giant gap since the beginning of March.

SearchTempest has no affiliation with craigslist, so until recently, we used Google to power our searches. Since Google is no longer getting the job done though, we’ve switched to Bing!

To be honest, Bing’s API doesn’t hold a candle to Google Custom Search. You can’t sort by date, specify a list of urls to search (Google’s ‘annotations’), or even reliably search within the url at all. (Bing does have a semi-hidden option, instreamset:(url):{text}, which is similar to Google’s inurl:{text}, but we’ve found it to be unreliable.)

That said, through some clever manipulation of query strings and a mess of hard-coded special cases, we’ve managed to come up with a Bing-powered craigslist search that’s quite functional. If you’re frustrated by not being able to search craigslist through Google like before, give it a try!

NextDesk Terra Electronic Adjustable Height Desk Review

Since I spend a good chunk of my time hacking on SearchTempest and AutoTempest, and a good chunk of the rest of my time playing Starcraft II and such, I end up at my desk for a large part of the day. I decided it would be a good idea to get an adjustable sit/stand desk so I don’t spend that entire time sitting on my butt.

I did a bunch of research and ended up deciding on the Terra from NextDesks.com. I’ve come across some significant pros and cons regarding both the desk and the buying experience that weren’t mentioned in any of the (relatively few) reviews I found online, so I figured I’d share.

NextDesk Terra

 

First the good. It does what it’s supposed to do. I got the extended version (73″ across) and it’s large, but not at all unwieldy or unattractive. It raises and lowers quite quickly (apparently fastest available), and has three electronic presets. There are a number of color options available, and you can customize things like where you would like the controls to be, cable management options, keyboard tray or no, etc. There is a tiny shudder to the up and down motion, but I certainly wouldn’t worry about anything on the desk shifting. Essentially it does what it’s supposed to do well.

The cons primarily have to do with the buying and assembly experience, but there are a couple to do with the desk itself that I will mention first. The main one is that the height presets have to be held down while the desk is moving to the preset height. This is not the case with their main competitor, the GeekDesk Max. What is particularly irksome about it is that I explicitly asked their salesperson about this before purchasing the desk, because I know some other competitors do have preset buttons that need to be held down. He assured me that their presets do not need to be held, which is simply not true. I’m going to give the benefit of the doubt and say he just made an incorrect assumption, but since I’m making a rather expensive purchase based on his word, I expect better.

Now, the NextDesk does adjust height quite a bit quicker than the GeekDesk, but when you don’t have to hold the button you can spend the time moving your chair, standing up/sitting down, and getting back to what you were doing while the desk is doing its thing. Since that time is much shorter but essentially wasted with the Terra, it’s essentially a tie as far as which I’d prefer. However, the GeekDesk is almost half the price. (The presets are still useful though. It’s nice to set your heights then not thinking about it, rather than always fiddling with the height trying to find the level that feels right.)

The other thing I’ve found with the desk itself is that a small chunk (perhaps 1/4″ x 1/8″) of the surface coating has apparently flaked off at some point. The solid bamboo surface of this desk is something that’s supposed to set it apart from the competition, so you don’t like to see the finish disintegrating almost immediately. (I have no idea when it came off, but I certainly haven’t dropped anything on the desk or anything like that.)

One other thing to be aware of with the surface too is that its color appears significantly lighter in person than in the color swatches on their website (or even the physical ones they mail out). Obviously the website ones will depend on the calibration of your monitor, but even looking at the swatch they mailed with the desk, my “dark” surface looks much closer to the “medium” color swatch. (Although when I took a picture of the desk with the swatches on it, it looked closer to the “dark” swatch in the picture, which explains why they look that way!) So this certainly isn’t a knock or anything, just something to keep in mind – it will most likely appear lighter in person than you would expect from looking at the swatches.

Finally, the process of buying and then assembling the desk definitely had some stumbling points. The good first though – they shipped the desk very quickly, and it was packaged extremely well. Essentially no chance of damage during transport, and it shipped in two separate boxes (for the top and the frame), which made things a lot easier to manage since it’s obviously large and potentially unwieldy otherwise.

However, even aside from the misinformation about the presets, I found their support to be somewhat underwhelming. To start with, I asked a simple question about shipping costs (I’m in Canada, so it’s cross-border shipping). Several times my emails went days or even weeks with no answer, and eventually I just gave up on the email conversation and resorted to phone calls. (And then I was promised callbacks on specific days which never came, again requiring me to follow up later.) I also asked them where the controls are positioned because I planned to set my working area up to the right side of the desk and wanted to make sure they wouldn’t be in the way. They told me that I can have it wherever I want, but if it’s not specified they put it about 6 inches from the edge. That sounded perfect to me, so I didn’t specify a position when ordering. That was a mistake, as the desk arrived with the controls installed about 18″ from the edge instead (right where my leg wants to be). I drilled some new holes and moved it, but shouldn’t have had to.

Then of course there was the presets thing, and when I wrote to complain about that after receiving and assembling the desk, I never received a reply. (It’s been about 2 weeks now.) And finally, their instructions are extremely poor. Again this certainly isn’t a reason not to buy the desk, but if you do get one, definitely read through them a couple of times before getting started. There were a couple parts where I had to do some dis-assembly because something that had to be done in an earlier step wasn’t specified until later (or at all). For example, the two legs are interchangeable, but the cables that run out of them to the central control box cannot be adjusted once the legs are attached. So if you don’t pay attention to which way they’re going when you attach the legs, you’ll end up having to take the whole thing back apart to fix it. There were also a couple guess and check steps, like the initialization process: “Press the Down button once or twice, holding it down.” Uhh.. ok. (I pressed it twice, holding it down the second time. That didn’t work though, so I tried pressing it once, holding it down. Still nothing. So I unplugged the desk, plugged it back in, pressed and held once, and it worked. Instructions fail.)

So, if you’re looking for an adjustable-height sit/stand desk, this one IS worth a look. Just be extremely explicit about how you want things set up, and be aware that regardless of what they say, the presets do need to be held down. Personally I would prefer not to support a company that treats customers this way, but there is quite a lack of premium electronic height-adjustable desks out there at the moment. That said, the GeekDesk is certainly worth a look, as might be this NewHeights desk. The main reason I wrote that one off in my research initially was that the presets had to be held down…

Hope that helps! Are any of you using an adjustable desk already? (Or just a standing desk?) What do you figure a company’s response should be after misleading a customer like this (assuming it was a mistake)?

Update – July 2014:
I wanted to update this post, as I just had a really good experience with Priya at NextDesk customer support. I finally decided to see if I could get warranty support for the shuddering issue mentioned in the comments, since it seemed to be getting worse. The response from custom support email was instantaneous this time, and she took me through a set of calibration steps, then when that didn’t help, readily shipped me a new leg along with a return shipping label for the (presumably) defective one. It looks like the company may be maturing, which is great to see. Hopefully this new leg works out!

Update 2 – Septembar 2014
They seem to be trying hard, but so far the first replacement leg they sent me was also damaged, and the second was the wrong color. I also still haven’t received any shipping labels despite asking repeatedly, so I’ve got a growing collection of desk legs littering my office…

SearchTempest Update

As mentioned in recent posts, craigslist has been making some changes lately that we have had to adapt to. (We have no affiliation with craigslist at all, so we don’t get any warning or help from their end when they change something; we just have to figure it out.)

In the past, we allowed you to open results from multiple craigslist cities at once, all on the same page using ‘iframes’. A couple months back, CL added some code to their site to prevent their pages being opened in iframes, so we had to find a new way. As a result we developed two new results modes:

  • Separate Cities – Similar in appearance to our old setup, but inside each city ‘frame’, instead of a results page straight from craigslist, we showed results from a third-party provider called 3taps. 3taps is an ‘exchange data API’, which got craigslist listings from the google cache, so they did not have to actually scrape craigslist.

  • Direct Results – The goal of this mode was to preserve the straight-from-craigslist feature of the frames. Since we could no longer link to craigslist results pages in frames, instead we created an interface whereby they could be conveniently opened in new windows. Essentially we open up a small navigation window on the left, with links to craigslist results that open in a larger window on the right. Since both remain visible at the same time, it lets you conveniently flip through results from multiple cities.

Recently there has been another development. craigslist has apparently instructed google to stop caching their results. (Note, that doesn’t mean their results have been removed from google, just that google doesn’t store copies of entire craigslist pages.) This effectively cuts off 3taps’ source for craigslist data. For us, it meant we needed to find yet another new way to do the Separate Cities mode.

So, what we’re doing now is powering that mode with a Google Custom Search. Basically this allows us to customize a Google search so it only returns results from certain sites. So we take your search at SearchTempest, then send a request to google with your keywords, along with a set of sites to search based on the zip code, distance, and category you entered. Google returns a bunch of results fitting those parameters, which we display for you. When you click on one of the results links, it your browser opens that posting right at craigslist in a new window.

There are a couple downsides to this google-powered approach. The main ones are that it does not support filtering by price or displaying prices in the results, and that you can’t filter by ads with pictures. Also, preview images only work if the ad was created with embedded html images, not the standard craigslist pics. If you need those features, we suggest using the Direct Results mode mentioned above, which should do everything you need!

So in summary, the Separate Cities mode is now powered by Google. It’s probably the most convenient option for most people. If you find yourself missing those price or image filters though, or if you just want to get your results straight from the source, rather than via google, you should give the Direct Results mode a try.

Next thing on our agenda, thanks to user feedback, is simplifying the results page. We’re going to be removing a bunch of tabs, consolidating the Separate Cities and All Cities results modes into one (since they’re both now powered by Google), and just generally making everything a lot more straightforward. Hope to have that ready for you soon!

Code Compression

Was thinking recently about how any good code base tends to go through a continuous cycle of expansion and compression. (This thinking may have been inspired by the recent frantic development work on SearchTempest in the wake of craigslist blocking framing…) The ‘expansion’ part is the standard stuff. Building something new, adding features, even fixing bugs most of the time tends to involve writing more code, causing the code base to expand.

However, if you only expand and never compress, eventually you will inevitably end up with a giant pile of pasta.

It’s critical to occasionally go through your code and simplify. Trace through the logic and figure out how it can be improved. Look at places where procedural stuff could be made object-oriented. Even just strip out legacy crap that isn’t used anymore.

Of course, this can be difficult to justify. There are always higher priorities, and it’s tough to put a bunch of time into a project that, in the best case, has no immediate visible effect. (Especially if you happen to answer to a manager who hasn’t personally done much/any coding.) And that’s the best case. It’s ironic, but this process of cleaning up code can very well introduce new bugs. After all, it may involve making fairly significant structural changes to a code base that is by all appearances working just fine. (And those bugs tend to make people… irate. Don’t do something like this then go away for the weekend.)

So, why do we bother? Here’s a similar issue: why do we bother researching sources of renewable energy? It has always -so far- been cheaper to just stick with fossil fuels. That may well continue to be the case nearly until they run out, since the incremental cost of extracting a barrel of oil does not increase linearly with its scarcity. But if we wait until we run out of oil, or until we destroy our atmosphere burning coal, it’s too late.

Of course, the consequences of ugly code are rather less dramatic, but the analogy holds. If you wait long enough, eventually you will be forced to clean up your spaghetti code because you’ll get to the point where adding one more hack will break the camel’s back. You’ll have a feature to add, or a bug to fix, and it simply won’t be possible to shoehorn it into the existing morass. When that day comes, it is NOT a fun day to contemplate redesigning your whole code base. Especially if the bug you’re trying to fix happens to be a critical one.

On the other hand, when such a fateful day rolls around, a clean code base can be a truly beautiful thing. A little irony: the best thing about nice clean code is that it makes it really quick and easy to slap on an ugly hack. And when your site’s down and the hysterical emails are rolling in, that ugly hack that gets you running again can be a beautiful thing too.

Or more generally, by periodically cleaning up your code, you make your job a lot easier the rest of the time. Of course, you could try to just ‘do things right the first time’. But even without deadlines (which takes us into imaginary-land), it’s pretty difficult to always keep the entire big picture in mind while solving a specific problem. Of course you should still try to write nice, clean, extensible code whenever possible. Sometimes though, you still have to take a step back.

In the real world, the cleanup of a given module will likely be spurred by some other development, which is okay. For me at least, there’s no motivation to sit down for the express purpose of prettifying code. But when you’ve already dug into something a bit and you start to see avenues for improvement -and you’re not in an absolutely critical time crunch- go for it! (If you’re always in a critical time crunch, you’re doing it wrong. Or someone is.) It’s just like cleaning in real life actually. Ever go to pick up a dirty sock and end up doing all the laundry then cleaning the entire house? Do that with code! (If not, go vacuum something. I bet your partner/roommate/cat will appreciate it.)

Nice clean code is a beautiful thing, but it’s elusive; you can’t aim straight for it. What you can do is write fairly decent code, then occasionally compress it. Channel your inner Superman and squeeze that code coal into a precious diamond. (Ha! Tied those analogies together!)

If it ain’t broke, now’s a great time to fix it!