OUTLINING

By default, the code editor displays an outline view of code. If you look at the first line in Figure 5-1, you’ll see a box with a minus sign in it just to the right of the line number. That box represents the outlining for the Form1 class. If you click this box, the editor collapses the class’s definition and displays it as a box containing a plus sign. If you then click the new box, the editor expands the class’s definition again.

Near the bottom of Figure 5-1, you can see that the RandomizeArray subroutine has been collapsed. The ellipsis and rectangle around the routine name provide an extra indication that this code is hidden.

The editor automatically creates outlining entries for namespaces, classes and their methods, and modules and their methods. You can also use the Region statement to group a section of code for outlining. For example, you can place several related subroutines in a region so you can collapse and expand the routines as a group.

Figure 5-2 shows more examples of outlining. Line 33 begins a region named Randomization Methods that contains two collapsed subroutines. Notice that the corresponding End Region statement includes a comment that I added giving the region’s name. This is not required but it makes the code easier to understand when you are looking at the end of a region.

FIGURE 5-2: The code editor outlines namespaces, classes and their methods, modules and their methods, and regions.

image

Line 57 contains a collapsed region named Utility Functions. Notice that this region is nested inside the Randomization Methods region.

Line 129 starts a module named HelperRoutines that contains one collapsed subroutine.

Finally, line 144 holds the collapsed ImageResources namespace.

Notice that the line numbers skip values for any collapsed lines. For example, the Randomize2DArray subroutine is collapsed on line 36. This subroutine contains 7 lines (including the Sub statement), so the next visible line is labeled 43.


COLLAPSED CODE COMMENTS
Notice that comments before a subroutine are not collapsed with the subroutine. You can make reading collapsed code easier by placing a short descriptive comment before each routine.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.75.235