Close and Go BackBack to Viget

Getting (And Staying) Motivated to Code

David Eisinger
David Eisinger, Web Developer, January 21, 2009 5

When you’re working on code written by another programmer — whether a coworker, open source contributor, or (worst of all) yourself from six months ago — it’s all too easy to get frustrated and fall into an unproductive state. The following are some ways I’ve found to overcome this apprehension and get down to business.

Tiny Improvements, Tiny Commits

When confronted with a sprawling, outdated codebase, it’s easy to get overwhelmed. To get started, I suggest making a tiny improvement. Add a named scoped. Use a more advanced enumerable method. And, as soon as you’ve finished, commit it. Committing feels great and really hammers home that you’ve accomplished something of value. Additionally, committing increases momentum and gives you the courage to take on larger changes.

Make a List

In Getting Things Done, David Allen says,

You’ll invariably feel a relieving of pressure about anything you have a commitment to change or do, when you decide on the very next physical action required to move it forward.

I like to take it a step further: envision the program as I want it to be, and then list the steps it will take to get there. Even though the list will change substantially along the way, having a path and a destination removes a lot of the anxiety of working with unfamiliar code.

To manage such lists, I love Things, but a piece of paper works just as well.

Delete Something

As projects grow and requirements change, a lot of code outlives its usefulness; but it sticks around anyway because, on the surface, its presence isn’t hurting anything. I’m sure you’ve encountered this — hell, I’m sure you’ve got extraneous code in your current project. When confronted with such code, delete it. Deleting unused code increases readability, decreases the likelihood of bugs, and adds to your understanding of the remaining code. But those reasons aside, it feels great. If I suspect a method isn’t being used anywhere, I’ll do

grep -lir "method_name" app/

to find all the places where the method name occurs.

Stake your Claim

On one project, I couldn’t do any feature development — or even make any commits — until I’d rewritten the entire test suite to use Shoulda. It was mentally draining work and took much longer than it shoulda (see what I did there?). If you need to add functionality to one specific piece of the site, take the time to address those classes and call it a victory. You don’t have to fix everything at once, and it’s much easier to bring code up to speed one class at a time. With every improvement you make, your sense of ownership over the codebase will increase and so will your motivation.

In Closing

As Rails moves from an upstart framework to an established technology, the number of legacy projects will only increase. But even outside the scope of Rails development, or working with legacy code at all, I think maintaining motivation is the biggest challenge we face as developers. I’d love to hear your tips for getting and staying motivated to code.

Priit said on 01/21 at 06:42 PM

I find a compatibility issues between Rails versions a problem in terms of motivation. Imagine a larger Rails application with lot’s of plugins. Upgrading this application to use newer version of Rails probably takes you far away from small chunks of improvements and commits ‘cos you have to update plugins and test things over and over. And therefore, if you see a lot of hassle in front of you it is a less motivation for upgradeing.

But if i want to stay in topic—small enhancements and changesets are indeed invaluable motivators. To get started, sometimes i’ll take an unimplemented (or broken) spec and try to fill it with test code. This is the shortest way get my otherwise-short-attention to problems i really want to solve.

Jerry Cheung said on 01/21 at 08:54 PM

It’s as if you read my mind with this blog post.  I’ve been completely struck down in motivation both at work and in my own personal pet projects.  To add onto your list, I think showing off is also a great moral booster.  I really enjoy having daily short scrum meetings to talk and listen to what everyone is working on.  On personal projects, I get the same good feeling by asking for feedback from friends.  Writing blog posts reflecting on completed technical challenges can also make you appreciate the work done.

TJ said on 01/21 at 09:49 PM

In my current job, we have a technical stand up after our morning stand up where someone from the team gets up and talks about what they did that was a little different from the normal flow of things. Maybe they used a named_scope, or perhaps they used a Presenter Pattern somewhere. They stand up and share it with the team. This is a great motivation not only to the person doing the talking, but also to other members in the team to strive to produce better code as well. It should also be noted that the technical stand up only occurs if there is something that needs to be shared. Otherwise its work as normal. The other useful thing that we used the tech stand up for is if a team member found some code smells and fixed it up, then he/she would talk about why that was a code smell and why the way they did is better. I know it sounds like the tech stand up is a time “sucker” but it changed the way we now work as a team and also the code that is produced.

Jacek Becela said on 01/22 at 04:16 AM

We do the same with the exception that we use “rak” instead of grep.

Jim McMahon said on 02/01 at 12:19 AM

One of the things I do to break the monotony is encourage the team to bring a new blog/forum each week to the meeting; for example, this week I noticed that Network Solutions has started a community for developers and designers located at www.linktogether.com.  Interesting.  We’ll have to monitor to see what becomes of it.

Commenting is not available in this weblog entry.

We're the Developers

at Viget Labs. We write about web development trends, tips, best practices, industry events, and our projects — all with an emphasis on Ruby on Rails.

Contact Us

Have any questions, comments, ideas, or secrets to share? Let us know.


What is the third letter in apple?

Sorry, you need to have Javascript enabled to use this form. (Don't blame us, blame the spammers!) If you'd like to contact us, please visit our Contact page.