Class View and Object Browser
Now that we have introduced key concepts of object-oriented programming, we present two features that Visual Studio provides to facilitate the design of object-oriented applicationsClass View and Object Browser.
Using the Class View Window
The Class View displays the fields and methods for all classes in a project. To access this feature, select Class View from the View menu. Figure 9.21 shows the Class View for the Time1 project of Fig. 9.1 (class Time1) and Fig. 9.2 (class TimeTest1). The view follows a hierarchical structure, positioning the project name (Time1) as the root and including a series of nodes that represent the classes, variables and methods in the project. If a plus sign (+) appears to the left of a node, that node can be expanded to show other nodes. If a minus sign (-) appears to the left of a node, that node can be collapsed. According to the Class View, project Time1 contains class Time1 and class TimeTest1 as children. When class Time1 is selected, the class's members appear in the lower half of the window. Class Time1 contains methods SetTime, ToString and ToUniversalString (indicated by purple boxes) and instance variables hour, minute and second (indicated by blue boxes). The lock icons, placed to the left of the blue box icons for the instance variables, specify that the variables are private. Class TimeTest1 contains method Main. Note that both class Time1 and class TimeTest1 contain the Base Types node. If you expand this node, you will see class object in each case, because each class inherits from class System.Object (discussed in Chapter 10).
Figure 9.21. Class View of class Time1 (Fig. 9.1) and class TimeTest (Fig. 9.2).
Using the Object Browser
Visual C# Express's Object Browser lists all classes in the C# library. You can use the Object Browser to learn about the functionality provided by a specific class. To open the Object Browser, select Other Windows from the View menu and click Object Browser. Figure 9.22 depicts the Object Browser when the user navigates to the Math class in namespace System in the assembly mscorlib (Microsoft Core Library). [Note: Be careful not to confuse the System namespace with the assembly named System. The System assembly describes other members of the System namespace, but class System.Math is in mscorlib.] The Object Browser lists all methods provided by class Math in the upper-right framethis offers you "instant access" to information regarding the functionality of various objects. If you click the name of a member in the upper-right frame, a description of that member appears in the lower-right frame. Note also that the Object Browser lists in the left frame all classes of the FCL. The Object Browser can be a quick mechanism to learn about a class or a method of a class. Remember that you can also view the complete description of a class or a method in the online documentation available through the Help menu in Visual C# Express.
Figure 9.22. Object Browser for class Math.
(Optional) Software Engineering Case Study Starting to Program the Classes of the ATM System
|