We, all programmers normally have a programming language of preference
and a favorite IDE. In my case it’s c# and Visual Studio. We think sometimes if
we can read and understand our own code it’s more than enough. When you were
doing single pet projects of course that was enough. Nobody is there to point
out bugs and you test your own code (only if you care to test). But when you
start doing very large group projects, your code’s quality plays a major role. Your
code must be well organized; all the classes, variables and methods must be properly
named and well commented. Because other developers in your team need to understand what you have done with the code. And your QA team members who do the testing need proper documentation to understand the functionality of your code.
Programmers normally are very lazy when it comes to
commenting. Even I was. And some of us have no idea how to do correct
commenting. Today I’m going to share an easy way to maintain the quality of
your code using few simple tools.
The tools I was talking about are extensions for Visual
Studio 2008+. One is StyleCop and
other is GhostDoc.
You can download them from above links and install them. I will illustrate how
to use them to improve the quality of your code.
StyleCop is a cool extension which can be used to analyze
your code. This is how you analyze your code with StyleCop.
- Right click on the class on your solution explorer. And select run StyleCop.
- It will generate a list of warnings and may be errors as follows. If you double click on them you will be taken to the line where the warning appears.
You can correct the spacing errors one by one. But what
about the ‘documentation header missing’ warnings? You have to write them for each
and every one of your classes, methods and variables, right? Not anymore. That’s
where our other extension GhostDoc comes in to play. It will do that hard work
for you. This is how it is done.
- When you double click on a document header missing warning styleCop highlights that property for you. What you have to do is right click on highlighted text and select ‘document this’ option GhostDoc provides you.
- This is how my newly generated comment looks like. Easy huh.. You can include any additional information you want to add in the header.
So I hope all the steps were clear. If you want any
additional info please leave a comment. In the mean time Happy Coding!!!
No comments:
Post a Comment