The best programmers are lazy
The great Larry Wall (author of Perl) claimed that laziness is one of the greatest virtues a programmer could develop. The best programmers are lazy in the sense that they do not write duplicate code or take pleasure in writing boilerplate code. They are efficient in writing code that follows the DRY, KISS and YAGNI principles.
Efficient IDE usage
Next to writing as few lines of code as possible (without compromising on readability ofcourse), being a lazy programmer also means using the IDE efficiently.
- Knowing when and how to use the various project and project item templates.
- Using keyboard shortcuts instead of navigating through long menus.
- Using code snippets instead of writing boilerplate code.
Ever since the 2005 edition, Visual Studio allows inserting blocks of reusable code, called code snippets, through shortcut keys (or the context menu, but truly lazy programmers don’t take away their hands off the keyboard).
I’m still amazed by the fact that so many .Net developers are still not aware of these code snippets. Using these can really speed up writing commonly used bits of code like properties with backing fields, try/catch blocks, foreach loops etc.
So if you want to be a lazy programmer learn these snippet shortcuts by heart!
prop- auto implemented property
propg- auto implemented property with private setter
propfull- property with backing field
if- if block
else- else block
try- try/catch block
tryf- try/finally block (oddly enough there is no trycf!)
for- for loop
forr- reverse for loop
foreach- foreach loop
switch- switch block
Simply invoke the snippet by typing the shortcut followed by
[TAB]. Here’s a list with more built-in shortcuts if you’re eager for more.
Get lazier: write your own snippets!
If you want to be as lazy as me you can easily write your own snippets as I’ve done for extension methods, unit tests and more. The Snippet Designer plugin can be useful if you don’t like editing the raw XML.
Enjoy lazy coding!