April 06, 2011 11:00 AM

Boost Your Coding Productivity

Tools for improving coding productivity using templates
Dev Pro
InstantDoc ID #135801
A key technique that developers use to increase productivity is to adopt coding paradigms, techniques, and tooling that let you generate code instead of writing it. Or, as the saying goes within the developer world: "Good developers write good code, but great developers write code that writes good code for them."

The Case for Code That Writes Code
In addition to boosting overall productivity while in the saddle, adopting tooling and techniques that generate code instead of making you write it out by hand usually results in better overall code within your application as well.

Typically this is true for one of two reasons. First off, generating code with parameters or via templates is a much better approach than the copy-paste-tweak approach that you were likely going to use anyhow in addressing repetitive coding needs. (Because we all know that copy-paste-tweak is a quick way to get things done—one that always results in a few days of debugging some crazy, indeterminate bug that you just can't track down because you know the code works just perfectly.)

The second reason that generating or using templates to create repetitive code is a better idea is because code that you take the time to template is code that has typically been tackled a metric bazillion times. The code is at the point where it's become an "idiom" in the sense that it's typically robust and coded enough that it is—you hope—better code than something you would just pound out spontaneously. Or, in other words, generated code typically tends to represent "better"' code by nature of the time and energy spent in parameterizing or templating it, making it provide additional benefits than the obvious DRY (don't repeat yourself) benefits that you'd think you'd be getting.

As such, I wanted to take a look at several techniques for boosting productivity that I've been using over the last year or so with great success.

ReSharper and CodeRush
Put simply, you're either a huge fan of JetBrains' ReSharper or of DevExpress's CodeRush. Personally, I don't care which one you use. But if you're a professional developer and don't use one of these solutions, then you're cutting yourself insanely short—and spending way too much time doing stuff you don't have to do.

Personally, I'm a big fan of ReSharper. And while I originally grabbed it for its refactoring support, unit testing augmentations, and its huge amount of other additional UI helps, tweaks, and productivity boosts, one of the things I love the most about ReSharper is its support for templates that make it so much easier for me to quickly code repetitive tasks. In fact, I use ReSharper's templating functionality all the time when creating new repositories and when creating individual methods within those repositories—because ReSharper's support for "surround-with" templates gives me the ability to easily tackle some custom considerations around caching that I leverage pretty heavily in many repository methods.

Likewise, while I haven't use CodeRush in a long time (or to much degree), I know that CodeRush supplies its own powerful templating features as well.

Of course, it always takes a bit of time and effort to learn how to use something like more advanced templating features (to say nothing of the additional time it takes to acquire the muscle memory needed to commit these approaches to shortcut keys). But I've always found that whenever I take the time to learn a new approach such as extended templating, the tiny bit of pain I incur up front is richly rewarded later on with drastic increases in productivity that pay off over and over again.



ARTICLE TOOLS


Comments
  • SiliconDragon
    1 year ago
    Apr 07, 2011

    Good intentions, but over-generalized. You should change your quote to: "Good developers write good code, but lazy developers write code that writes good code for them."

    Your discussion of templates is rather naive and woe to anyone who starts slapping templates into their app w/o fully realizing the implications and side-effects. But for general everyday-use code, templates are great time-savers, agreed.

You must log on before posting a comment.

Are you a new visitor? Register Here