Give Me a Break!

•January 17, 2008 • Leave a Comment

Awhile back I watched a talk that Kent Beck gave entitled Ease at Work. The video was originally published by Agitar but has since been distributed on YouTube and Google videos. The first installment can be found here and I’m fairly sure that the others will be accessible from there. So in these talks Kent mentions the “Hero / Idiot Pendulum” describing two extremes that he as a programmer swings between as he works. I find this very true of myself as well. One moment, I’ll be doubting my competence as a programmer and the next I’ll be declaring my genius. Neither is accurate but that’s not the purpose of my post today. Today I’d like to talk about one way I’ve found to pull out of the idiot swing and back into a healthier and more productive frame of mind.

My wife and I were married in college and I now work at home so she has seen me in this sorry state more times than I’d like to admit. “Take a break” she’ll say to me. “Go get some fresh air; get your mind off it for 15 minutes.” Sadly, taking this break is the last thing I want to do in these situations. I want to have victory! I want to prove my worth as a programmer so there I sit, slogging away in the wrong frame of mind.

Today I found myself mired in thoughts of my own idiocy as I worked through a difficult issue and once again, I didn’t want to take a break. “A break would be a waste of time,” I thought. “This is a tricky problem and I need to come up with a timely solution. This break will only put me 15 minutes behind.” Finally though, after some more staring at the screen and some divine pushes out the door, I caved. I came out of my office, played a 10 minute card game with my wife and played with my dog in the cold air for another 10. Twenty minutes down the drain? Not at all! I came back to my desk refreshed and found a solution in 15 minutes. Sure I think the Lord helped me to see it but I was in more of a listening mood than I was before. How much time would I have spent otherwise? I’m confident it would have been more than 35 minutes and my wife and dog got a little benefit to boot.

I see many friends and colleagues who do technical work down in these doldrums at one time or another, unwilling to step away because they think it will waste time. Often they’ll work late into the night. I’m fairly confident though, whenever you find yourself slogging away, swinging down toward the idiot side of the pendulum, it’s time for a change of context and yes, I think fresh air and exercise can be the best change in our sedentary line of work.

As for me, lesson learned? We’ll see. I find that I’m kind of dense when it comes to this sort of thing but hopefully next time I’ll be a bit quicker to invest some break time towards a solution.

TextMate Footnotes

•December 11, 2007 • Leave a Comment

I read Glenn Vanderburg’s blog quite a bit and came upon this post awhile back talking about TextMate Footnotes, a tool that has boosted his productivity quite a bit. I’ve found some use for it as well. Granted, it won’t pop up a debug window for you in your VisualWorks image but, we can’t have everything we want.

Why write about it again when several others have? Well, I receive such a large amount of traffic to my blog that I consider it my duty to share handy tools with others that may never read Glenn’s (and others’) blogs……OK, I admit it, no one reads this blog and I’m just using this post as a place to easily find the links to the plugin when I’ve forgotten where they are months from now. The Rails Wiki describes how to install the plugin here.

And now a large link for me when I’m later scanning this post to find it.

TextMate Footnotes

If you’re still reading, TextMate Footnotes, once installed as a plugin in your Rails project will add handy links to the bottom of each of your pages (after a server restart of course).

Footer Screenshot

The Edit links will take you directly to your open TextMate app to the controller, view, layout, etc. file. It saves you from having to figure out where you’re at and then navigating there yourself. Granted this was no great chore in TextMate and Rails anyway but that 10 seconds you spent doing it each time adds up. The Show links will insert various data in-page, like a dump of the session, cookies, etc.

Even handier are the additions to the Rails development error page. Now each item in the stack trace is a link to that file and line.

Exception Screenshot

Definitely a time saver!

Leopard Dock Folder Previews

•November 14, 2007 • Leave a Comment

So Leopard definitely has some cool new eye candy. The new dock is pretty and that Finder coverflow thing is pretty neat, though I rarely use it. I also like the new Fan and Grid functionality for the folders in your Dock.

Dock Folders

However, I’d really enjoy not having those Dock folder previews. My Applications folder now looks like the Address book with the Automater bot peering over it. My Downloads folder currently looks like a Stuffit archive and my home folder looks like…well, you get the idea. I even spent entirely too much time picking out cute icons for those folders in my Tiger days so I’d easily be able to pick them out. Here’s eagerly waiting for a way to disable that feature.

Update – 4/18/2008

I don’t know in what version this feature has been made configurable but now you can configure a folder on your dock to “Display as Folder” rather than a “stack”. Also, it looks like they’ve added the ability to open the folder as a “list” which is the old fly-out menu version, the only option available in pre-Leopard OS X. I think these features can be attributed directly to the influence of this blog in the Mac community…maybe not.

Convert to Sibling Refactoring

•October 8, 2007 • Leave a Comment

Recently the company I work for has been doing a lot of work in the web app framework Seaside. Up to this point we’ve done all of our green field projects in Rails. However, our president has a Smalltalk background and we’d both been impressed by what we’d seen of Seaside. We settled on a VisualWorks, Linux, PostgreSQL platform and went to work.

So recently I came across a refactoring that I often did in Ruby, etc. and was pleasantly surprised how quick and easy it was to do in VisualWorks. So the scenario looks like this: I create a class, find that I need another class that does most of the same stuff and would fit nicely into an inheritance hierarchy. To accomplish this, I’d often copy the class wholesale and change the bits that were different so I could see how much these things actually had in common. So from there, the goal of my refactoring would be to create a superclass for the two, put the common methods in that superclass and have the differences in the children. Sometimes I’d throw some exceptions in the methods I want the children to implement in the superclass. In Ruby though there seems to be less reason to do this, as a NoMethodError is nearly as explanatory as anything else you could raise. However in VisualWorks creating a new class allows you to auto-generate methods that require implementation by an ancestor. Anyway, I digress.

VisualWorks makes this refactoring easy with Convert to Sibling and Push Up. Simply execute the Convert to Sibling refactoring on one of your classes which creates a superclass with every method throwing a subclass responsibility error. Then in your subclass you can execute Push Up refactorings on the methods you want to exist in your superclass. All that’s left is to take your second class, change the parent to your new superclass and remove the methods the superclass implements.

Handy!