The Basics - Coding Conventions
(Page 3 of 8 )
Although this chapter isn’t about coding conventions, and it doesn’t even contain a lot of code, we want to get the message across, before you start e-mailing us about our coding conventions. We use the following Microsoft-endorsed and/or recommended guidelines:
We’re aware that some of these documents overlap, but they will give you an idea of why and how we name our classes, constants, variables, and so on.
NOTE VEA 2003 comes with a complete set of data types supported by the four programming languages you get with the VSEA edition: C#, C++, J#, and VB .NET. You can also choose from the Interface Definition Language (IDL) data types, which means you might avoid having separate models for different target languages. However, the IDL data types don’t support all the data types in the three mentioned programming languages. On the other hand, IDL does support data types that are supported in only some of the three programming languages. One such example is unsigned data types, which aren’t supported in VB .NET. One thing you can do is to use IDL data types for all the generic data types, and then use more language-specific ones when they are necessary.
Now that you’ve named the class and created the attributes for it, you need to create the operations for it. Exercise 1-3 demonstrates how to specify operations and their parameters.
EXERCISE 1-3
- Open the UML Class Properties dialog box (if it isn’t already open).
- Select the Operations category from the Categories list.
- Create a new operation by clicking the New button.
- Type Logon in the Operation column.
- Select VB::Boolean from the Return Type list.
- Click the Properties button while the Logon operation is selected to open the UML Operation Properties dialog box.
Select the Code Generation Options category from the Categories list.
Select Procedure from the Operation Kind list.
Select the Parameters category from the Categories list.
Create a new parameter by clicking the New button.
Type userID in the Parameter column.
Select VB::String from the Type list, and ensure “in” is selected in the Kind column.
Repeat steps 10 through 12, creating a new input parameter with the name password. The UML Operation Properties dialog box should now look like Figure 1-4.

Figure 1-4. The UML Operation Properties dialog box showing parameters
14. Click OK.
15. Select the Code Generation Options category from the
Categories list.
16. Select Visual Basic from the Target language list.
17. Click OK. You return to the class diagram, which is updated to
reflect the changes you’ve made. (You may need to select
View -> Zoom to adjust the class size on the diagram.) The class
has a new name, Logon, and the attributes and operations are
displayed, divided by a horizontal line, as shown in Figure 1-5.

Figure 1-5. The Class diagram with the updated class
Now that you’ve actually completed the class skeleton for the example, let’s take a moment to recap what you did to get to this point:
- Created a new UML model diagram
- Added a class to the diagram
- Created two attributes (private variables) for the class
- Created a public operation (procedure) with two input parameters
- Specified the target programming language as Visual Basic
Now you just need to save the UML model, following the steps in Exercise 1-4.
EXERCISE 1-4
- Select File -> Save.
- Browse to the location you want to save the model in and type a name in the Save As dialog box. Save the model with this name and path for easy access
in later exercises and chapters: \EDWVSNETUMLMSF\Chapter 01\ VB .NET\Logon.vsd.
3. Click OK.
This article is excerpted from Enterprise Development with Visual Studio .NET, UML, and MSF by John Erik Hansen and Carsten Thomsen (Apress, 2004; ISBN 1590590422). Check it out at your favorite bookstore today. Buy this book now. |
Next: Generating the VB .NET Code for the Logon Class >>
More .NET Articles
More By Apress Publishing