Artifacts > Analysis & Design Artifact Set > Design Model... > Design Class > Guidelines > Designing Classes in Visual Basic
Guidelines:
|
This is an
outline of class design guidelines applicable to a Visual Basic® project
using Rational Rose® as a modeling tool; these guidelines might be
further refined to fit into a specific project environment.
These guidelines are structured according to the Activity: Class Design, presenting specific guidelines for each step within that activity. |
The following books and documents are referred from these guidelines:
The Rational Unified Process (RUP) description is based on UML terminology, meaning that it in some cases need to be mapped onto corresponding Visual Basic® and COM terminology. There also exists an option in Rational Rose® that can be set to view the model using COM terminology; when doing this, the following terms are changed:
RUP/UML |
Visual Basic®/COM |
operation | method |
parameter | argument |
attribute | property |
This must be kept in mind when interpreting RUP descriptions.
Refer to the Rational Rose® add-in help file, "Rose Visual Basic," section "Reference," subsection "Model to Visual Basic Mapping."
A boundary class representing a part of the user interface is likely to start out as a form.
A boundary class representing interaction with external systems represents in most cases a reference to an ActiveX component or a DLL. This is done by declaring an object variable or a DLL procedure, respectively, and then use this variable or procedure to access functionality. We recommend that this object variable or procedure declaration is done within the same module, and that the usage of the variable or procedure is encapsulated within the module. This will localize changes to the external interaction.
An entity class is likely to start out as a class marked as persistent. When this "data class" has been refined, DDL scripts defining the corresponding database tables can be generated (see "How to Handle Persistency" below).
A control class is likely to start out as a class module.
Define Visual Basic methods in terms of sub, function and property procedures.
Refer to the Rational Rose® add-in help file, "Rose Visual Basic," section "Reference," subsection "Model to Visual Basic Mapping," subsubsection "Method Mappings," for details.
For method naming guidelines, refer to "Visual Basic® Programmer's Guide," part 2: "What Can You Do With Visual Basic?," section "Programming with Objects," subsection "Naming Properties, Methods, and Events."
Note: "Designing attributes" means "defining class properties" in a Visual Basic® context.
From Rational Rose, class properties are translated into data members. By default, Rational Rose® does not generate the property Get, Set and Let procedures corresponding to each property. A model property allows the user to turn on automatic generation of property procedures.
Refer to the Rational Rose® add-in help file, "Rose Visual Basic," section "Reference," subsection "Model to Visual Basic Mapping," subsubsection "Properties," for details.
For property naming guidelines, refer to "Visual Basic® Programmer's Guide," part 2: "What Can You Do With Visual Basic?," section "Programming with Objects," subsection "Naming Properties, Methods, and Events."
Associations map to pairs of data members in Visual Basic®. The name for each data member is taken from its association role name.
You can use associations (and aggregations, see below) to model so called "object models" in Visual Basic®; refer to "Visual Basic® Programmer's Guide," part 2: "What Can You Do With Visual Basic?," section "Programming with Objects," subsection "Object Models."
In Rational Rose, associations can be described in detail by assigning a variety of adornments and properties. These adornments include association direction, roles, multiplicity, navigability, aggregate, access, containment, role documentation and constraints, association classes, and qualifiers.
Refer to the Rational Rose® add-in help file, "Rose Visual Basic," section "Reference," subsection "Model to Visual Basic Mapping," subsubsection "Relationships," subsubsubsections "Association Relationship and Advanced Relationship Mappings," for details.
An aggregate relationship is conceptually the same as an association with the aggregate adornment set. Aggregate adornments have no effect on code generation, nor reverse engineering, in Rose. Also, the aggregate association is navigable on both ends, and data members are generated for each of the associated classes.
Depending on the type of aggregation, you should clarify the design as follows:
Refer to the Rational Rose® add-in help file, "Rose Visual Basic," section "Reference," subsection "Model to Visual Basic Mapping," subsubsection "Relationships," subsubsubsections "Aggregation Relationship and Advanced Relationship Mappings," for details.
In Visual Basic®, the closest correspondence to the generalization relationship is the implements construct. Thus, for a generalization relationship between a subclass B and a superclass A, Rational Rose® generates the following code into B's class module:
· An Implements A statement
· An object of the superclass
· Copies of A's public methods, including default dispatching implementations that delegate to the parent class A
Refer to the Rational Rose® add-in help file, "Rose Visual Basic," section "Reference," subsection "Model to Visual Basic Mapping," subsubsection "Generalization Relationship," for details.
Regarding the implements construct, refer to "Visual Basic® Programmer's Guide," part 2: "What Can You Do With Visual Basic?," section "Programming with Objects," subsection "Polymorphism."
Declare, raise, and handle the corresponding events.
Refer to the Rational Rose® add-in help file, "Rose Visual Basic," section "Reference," subsection "Model to Visual Basic Mapping," subsubsection "Events," for details.
For event naming guidelines, refer to "Visual Basic® Programmer's Guide," part 2: "What Can You Do With Visual Basic?," section "Programming with Objects," subsection "Naming Properties, Methods, and Events."
Methods (UML) can be specified on the Semantics tab of the (VB) method specification in Rational Rose. The (UML) method pseudo-or implementation code will be code-generated as a comment within the corresponding method in Visual Basic®. This comment can then be used as a starting point for the (VB) method implementation by removing the "comment ticks."
Rational Rose® does not support code generation from state machines. However, you should still define state machines in Rational Rose® if the objects of a class exhibit interesting state-controlled behavior; this will provide valuable information to the implementer of the class.
Refer to "Visual Basic® Programmer's Guide," part 2: "What Can You Do With Visual Basic?," sections "Creating a User Interface and Using Visual Basic's Standard Controls."
Also refer to Guidelines: User Interface (General), for more information on how to create user interfaces.
Refer to "Visual Basic® Programmer's Guide," part 2: "What Can You Do With Visual Basic?," section "Programming with Components."
Also refer to the Rational Rose® add-in help file, "Rose Visual Basic," section "How to…," subsection "Add Existing Software Components to a Model," for details.
Refer to "Visual Basic® Programmer's Guide," part 2: "What Can You Do With Visual Basic?," section "Debugging Your Code and Handling Errors."
Also refer to the Rational Rose® add-in help file, "Rose Visual Basic," section "How to…," subsection "Generate Visual Basic Code," subsubsection "Generating Error Handling Code."
Refer to "Visual Basic® Programmer's Guide," part 2: "What Can You Do With Visual Basic?," section "Accessing Data."
If you are using the professional and enterprise edition of Visual Basic, also refer to the "Guide to Data Access Objects."
Also refer to Activity: Database Design, for more information on persistency issues.
Also refer to the Rational Rose® add-in help file, "Rational Rose," section "Concepts," subsection "DDL Code Generation," on how to generate DDL code.
Refer to "Visual Basic® Programmer's Guide," part 2: "What Can You Do With Visual Basic?," section "Designing for Performance and Compatibility."
Refer to "Visual Basic® Programmer's Guide," part 2: "What
Can You Do With Visual Basic?," section "International Issues."
Rational Unified Process |