4 Lazy Ways To Stop Yourself Being Lazy
Here are four tricks I use to try and encourage myself to write the correct code at the right time.
- Use the Compiler to catch work that isn't done yet.
- Before writing a method, write the code that calls that method.
- That way, when I try to compile, errors will be reported for any methods that aren't yet written.
- Write a 'TODO:' comment.
- That way I can still compile but can track down the items that aren't done yet.
- Write a Unit Test that catches each problem as it is foreseen.
- That way while my code might compile, nUnit will tell me that the full story is a little more complex.
- Use Debug.Assert statements to hard-code your assumptions. Helps you find when your assumptions are wrong.
You can bounce from any one of these methods to any other. The order can go something like this:
- First write 'pseudo code' with each line labelled as 'TODO:'
- Convert the pseudo code into calls to fictional methods/properties. (Methods/properties that aren't written yet).
- Next, write the outline of these methods, but populate them with TODO's.
- Maybe now (or sooner) write unit tests to test the empty methods.
- As the tests are run, add some todo's or even some code to the methods.
- ...Continue compiling, writing, testing, planning -- all together.
The advantage of this kind of approach can be that it helps you capture your thoughts (getting-things-done style) before you get too bogged down in the implementation detail. And it does it in a way that leans on the tools available, to ease the burden on your memory.
Sooner or later you do of course have to write the actual code -- but using these tricks to scope out, design and view from a high level, can help you cut down and re-use code, long before you've spent time writing it.
Next → ← PreviousMy book "Choose Your First Product" is available now.
It gives you 4 easy steps to find and validate a humble product idea.