Know Your IDE (Part 1)

14. July 2010

In college, I come across a lot of people who have never used any sort of Integrated Developer Environment (IDE) besides notepad or some other enhanced text editor like ConText, Notepad++, or Vim. In our programming classes, our professors are busy teaching us programming concepts. They brush over the absolute basics about building and running a program, but never touch on the subject again. Now I don't blame my teachers for not covering how to use Visual Studio, I know they have a lot of C++ to teach us, but after a year and a half of programming in Visual Studio, I still see people looking for compile time errors in the Output window, or clicking "Start Without Debugging" when debugging is exactly what they want to do. Some of the most basic of functions, they're struggling with because they don't know what Visual Studio has to offer. I'd like to take some time to point out some of the more necessary functions Visual Studio has to offer, these are a few of the must needs in order to efficiently handle your time. I'll be describing where you can find the features in Visual Studio 2010, the latest/greatest in the line of Visual Studios. If you don't have VS2010, you can find the Express Editions here, I recommend C#, but to each their own.

The Error List: Errors can be confusing enough as is. With short concise names, new developers can sometimes struggle to decipher what the error actually entails. Worse than that, I've seen a lot of my friends just starting in Visual Studio trying to read and understand what is and what isn't an error out of the Output window (a textual output section that, by default, lies across the bottom of Visual Studio). The log quickly gets filled with line after line of buzzwords, file paths, error codes, and parameter settings. It's a head ache for even the best developers to try and read through. Although many developers have found the Error List, those of you who haven't will definitely thank me for pointing this out. If you go to View > Error List in the menu bar, or by pressing Ctrl + W then E, then the Error List will make it's self available and you can close the output window (click the output tab, and click the X in the upper right hand corner of it's small window). The Error List will give you a table of information about each compile time error found during building. It contains 3 main filters: Errors, Warnings, and Messages. Each can be toggled on and off to filter what is shown in the table. Errors must be handled in order for the build to complete successfully. Warnings are not required to be handled in order for the project to be built and run, but might provide for more stable, reliable code and should at least be read before being disregarded. Messages are notifications and no task is implied. In the table, you get information like the description of the error, what file the error can be located in and exactly the line and character that the error can be found out. To save time from having to locate the error, you can also double click the row in the table and it'll take you directly to the site of the error (if the error is associated to a line, some errors may be more general such as references to outside files). It's a fairly simple window, but makes your experience with Visual Studio much more tolerable and errors easier to find and fix.

The Class View: Joining a project that was started without you can be hard, especially the bigger the project is. Reading through files and files of code just to find out what classes and methods are available is a headache waiting to happen. The Class View can help organize your thoughts and display them in a great tree structure. If it's not already shown when you start Visual Studio and load up your Solution, you can go to View > Class View in the menu bar or press  Ctrl + W then C. Usually pinned on one side of Visual Studio or the other, the class view breaks down the solution to it's syntactical components, regardless if they're split across several files or not. The first layer of the tree is made up of the projects in the solution, just for good grouping. As you expand, you'll go through the available namespaces in that project as well as the references that project has. Inside the namespaces, you'll find the available Classes, Enumerations, Structs and Resources in that namespace. Upon clicking any of them, the bottom half of the Class View window will change to display the contents of what you clicked on, such as enum values, variables and methods, and resource items depending on what you clicked in the upper half of the Class View. Here, there's a nice, ordered collection of what has been developed so far in the solution, regardless how messy your coworker's code is. This window also makes for a great way to navigate the files because you can double click just about anything it displays and it'll take you right there.

XML Comments: This one is less of a feature of Visual Studio in the fact that it's not a window or a fancy key combination. Regardless of the fact you won't find this one in the menu bar, this feature is probably one of the most important for both you and the people that'll work on your projects with you or after you. Dependant on what language you're programming in, you can add XML-based comments that are attached to variables and methods. You simply go to the line above what you want the comment to associate with and you place three comment characters on the line. In C#, it's ///, and in VB.Net it's '''. Upon the third comment character, the comment will expand out with XML tags for various attributes of the code segment you placed the comment above. For most variables, you simply place a description inside of <summary> tags. For methods it adds other tags based on the signature of the method, including a tag for the return type and tags for each parameter (including generic type parameters) in addition to a summary tag. Not only does this make commenting your code easy and thorough, it also helps when you call to use those methods or variables. When Intellisense displays a method that you've added these comments to, it'll display the comments you placed in the XML tags at the proper times to help remind you what everything else. Not that these should be the only comments you leave in your code, by all means continue (because you ARE already commenting your code, right?) commenting complex lines of code that may not be clear, or explaining why you did what you did instead of leaving your obscure code block as a riddle for your coworkers or class mates. It's not clever or easily respectable to come up with a highly illegible section of code and leave it's mechanisms a mystery, even if the code is highly efficient at whatever it does. At the very least, explain What it does, even if you can't concisely explain How it does it.

These are just a few things that can help efficiently present information to you and/or your fellow developers. Simplifying some of the tasks that would otherwise take up your time can prevent head aches and help you stay focused on what you're really here to do: develop working code. There are many more things your IDE can do for you, I'm sure I'll post more about them later. Know some of your own features you feel are must know time savers? Leave them in the comments.

Development ,

blog comments powered by Disqus