ReSharper Jedi are the guardians of quality and productivity in the .NET world.
ReSharper Jedi use their powers to improve and advance source code, never to degrade.
ReSharper Jedi respect all developers, in any language, with any tools.
ReSharper Jedi serve others rather than ruling over them, for the good of the .NET world.
ReSharper Jedi seek to improve themselves through knowledge and training.
So what would be the major skill ReSharper Jedi should master? I think it is Coding in Reverse. This technique is widely used in test-driven development, I believe. However, it is so effective that every developer should master this skill regardless of programming style. Main principle could be described as follows:
Use Before Declare.
1. Learn to like red code.
2. Always begin with expressing your goal.
3. Deredify your code.
There is one thing to dislike, though. Automatic completion as you type doesn't work well when there are undefined symbols. However it seems to be more about lack of support in tools than fundamental limitation of the technique.
Let's see how does it work.
red indicates unresolved symbols which are just not there yet. At this point I can easily continue writing code for Main method and change my mind any time.
I've expressed my goal pretty well. See how I changed CommandLineParameter to ICommandLineParameter, when I decided that interface would be better. Also, I was able to use "foreach" Live Template to iterate over collection of undefined type.
Okay, now I have to deredify my code and create some methods and types. Where is my light
Now we need to fill methods with real code, and I will show how to use the Force by implementing ParseCommandLine. We again begin with typing our goal:
Several keystrokes, quick fixes, live templates, some typing and we get to another point:
I use the Force and create class which not only contains required constructor, but also implements interface!
I leave it as an exercise to finish the sample code for anyone who want to practice this technique. Implement ProcessParameter by using some ICommandLineParameter members before declaring them, then quick-fix your way into declaring them, then use Jedi skills and implement members on the SimpleParameter.
Have fun and may the Force be with you!
Note: Some or all of the features mentioned in this article may be available only in latest EAP versions of ReSharper.