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.
Code in 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.
9 comments:
This "programming by intention model" style isn't unique to ReSharper, I've been reading about it and using it for years.
Like everything, though, ReSharper just makes it faster and more pleasant.
Martin, I don't claim it to be unique, or that we invented it or we have a trademark on it :) I just want to let people know about this style, because it is very productive, and actually I rarely see people using it.
Can you share some techniques you use in this coding style?
Thanks for the great posts on ReSharper. Please keep them coming!
Erik,
I will post more after ReSharper 3.0 will be released. I just have no time now. I will post soon about what's hot in this new version, sometime next week.
Don't forget Key Jedi in the search for Jedi references, Ilya :)
BTW - awesome video! Should start a blog on music to code to....I like some Tricky or Massive Attack myself.
Heh. Wouldn't it be fun if there was a plug-in that changed the "light bulb" icon to a light saber?
Sean, Jedi Key is on my list of course, but as I pointed out somewhere else, it should show VS command name too.
Joe, that's great idea! I think we may prepare ReSharper a bit for such a plugin ;)
I'm really digging version 3.0 so far!
Post a Comment