Sunday, April 1, 2012

VS2010: Objects Navigation Usability Issues

By Mahmoud M.Orabi
When working on visual studio or any development IDE, you are going to need to navigate to different objects declaration which means that this feature must be too usable; otherwise, this will slow down your performance at work. Visual studio view object definition way is not that usable especially when you navigate to system resources. In addition, the object viewer seems detached from the source editors which makes it more difficult for the developer to use.


Download and Install Microsoft Visual Studio C# 2010 Express


Start a new “Windows Form Application”. So you will have a default form class created and its associated resources set.
Open the Form.cs file, and drag a button to your form. 

Double click on the dragged button, and make a call to show message box. For example:
private void onMyButtonClick(object sender, EventArgs e) {
            MessageBox.Show("Show Something");

While working, assume that you would like to go to MessageBox declaration. In that case you can highlight or put the keyboard cursor at MessageBox, and right click and select “Go to Definition” or just simply press F12. This will take you to the definition of that class. But it will be abstract definition with no implementation. This is not an issue as that class doesn't not have attached source files.
The opened editor will show the namespace details for the opened editor and its operations (which is good):
Now, we know that the namespace is “System.Windows.Forms”. Assume that you would like to know what else is in that namespace. Will you be able to do that directly from that editor? The answer is no. Even, you are not able to do so using the Solution Explorer that is shown by default and you will find that it does not refer to this object.
In order to do that, you will need to use the “Object Browser”. You can bring it by using “control+ W+ J”, or by clicking on the object browser button action:

From the “Browse” selection, choose “My Solution” so this will bring the current objects in your active project:

Well, this is not usable as it seems that you are trying to locate the definitions manually, and you are doing that away from the code editors. Even the browser does not provide a way to filter the displayed items in the explorer. This means that you will need to scroll down and locate the items yourself. The namespace that we are looking for is “System.Windows.Forms” so you will need to scroll down to expand it:

Assume that you would like to open the definition of “ComboBox”. You will be able to see its methods and main operations which are usable to help you to understand how to use it:

However, there is no feasible way to show this object in the document editor. This only works for the user’s created object. For instance, “Form.cs” can be opened in the code editor using the option “Go to Definition”:
This option does not work for the system objects. Although it is not that big deal since we are able to see the definition from the browser tool directly, it is still missing usability support that we are not able to see it in the code editor.
In addition, it does not provide a way to filter items in the tree so it will be more complicated for large projects.
One more thing, the Object Browser is totally separated from the code editors which makes it totally difficult for someone to sync between they want to browser, and what they have opened.
This becomes even worse if you would like to take a quick look at different code definitions on classes that have their code visible in your solution. For instance, you can have a number of 20 classes in a given namespace. You would like to navigate all of them in the code editor. This means that you will need to go though this process 20 times which will lead you to massive number of clicks for something you should expect 20 clicks or barely more.


The “Object Browser” must be associated with the current opened code editors. For instance, when I select a class “Class1” it should be selected as well in the Object Browser window. The same would be in Object Browser, that when select “Class1” this will bring its code editor into focus.
We must also have a tree explorer view that will help us to quickly navigate to the classes directly without needing to switch between different views. The way it works is by focusing on the current namespace and shows it as a parent node on that explorer, and you can simply see the list of classes under that namespace, and you double click each class to open its code editor directly. This will reduce the number of clicks while investigating some code. Moreover, it would be nice to have the capability to filter tree nodes will make it more usable especially for the large projects cases.


We must be able to quickly go to different objects code editors without needing to have many steps in order to do that. This is very important when you are reading codes that have some associated binary assemblies with less documentation , which is unusable the way that we have with the “Object Browser” in visual studio.

No comments:

Post a Comment