Creating Web Based Comments


There are times when you need to explain thecore structure and logic of your program, having an intention to makeit encapsulated and hidden at the same time. It always pays to keepaway your actual coding from the reach of your client, and in somecases, from your fellow-programmers. So in such cases, you need to givea bird-eye view of your program, which encompasses the number ofclasses and a brief description of methods and variables used in them.This information is more than enough for anyone to familiarize himselfwith your program.

Fortunately, Microsoft .Net programmers werevigilant and kind enough to provide us with a feature that is amazinglyeasy and fun. You can view the structure of your code using codecomment Web reports. These reports display information about thestructure of your code in a series of .htm pages. If you are coding inC#, you can also add custom comments to your code that can then displayin the report. The feature is provided in none other than VisualStudios .Net IDE. Here in this article, I am presenting the way it isdone. Consider a very simple sample project to make the web basedproject report.

namespace UsingWebComments
{
using System;

/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: Add Constructor Logic here
//
}

public static int Main()
{
//
// TODO: Add code to start application here
//
Class2 PrintName = new Class2();
PrintName.Display();
return 0;
}
}

class Class2
{
private static string Name = "Faiza Ajaz";

public void Display()
{
Console.WriteLine(Name);
}
}
}

The program is saved as UsingWebComments. Ithas two classes namely Class1 and Class2, both having one function eachnamely Main() and Display() in Class1 and Class2 respectively. Class2has a private and static string variable. Let's see how a it is dealtby the feature under discussion.

1. With the above program displayed in the code window of the IDE,

Go to Tools -> Build Comment Web Pages

2. You'll see a dialogue box with options in it. Let's discuss them briefly.

Build for entire solution
This option creates .htm pages for the structure and code comments for all of the projects and files in the solution.

Build for selected projects
This option creates .htm pages for the structure and code comments only for the projects selected in the list.

Save web pages in
Specifies thelocation where the .htm pages are to be saved. Type a path in the textbox or select Browse to navigate to a path. By default, the comment webpage is saved in the directory where your project is saved.

Add to Favorites
When selected,creates a shortcut in the Favorites window to the .htm pages generated.When you choose OK, the Add to Favorites dialog box appears, allowingyou to enter a name for the link. We're not adding our project infavorites here.

3. Click OK to finish the process.

Voila!!! Mission accomplished. The Web BasedComment Report has been created. Just browse to the folder where youhave saved it and you'll see something like this.

Clicking on UsingWebComments will lead you the view shown below.

Now you can view the details of your project from here. My project in this report would look like this:

I believe it is justified to comment that thisfeature is highly important and productive, as it allows quick and easypreparation of a Web Based Project Report and can save you from a lotof trouble.

Twitter Digg Delicious Stumbleupon Technorati Facebook Email

No comments yet... Be the first to leave a reply!