Showing posts with label Naming Conventions. Show all posts
Showing posts with label Naming Conventions. Show all posts

Wednesday, October 27, 2010

Mutators: Set

Classes may contain mutator behaviors for some or all of their states. This enables other objects to change the value of a state. A mutator behavior is usually implemented as a subroutine, unless there is a requirement for a return message - such as a confirmation that the change took place, in which case you would use a function (which could return a value, such as True or False).

A setter subroutine requires a parameter which represents the new value of the state.

For example, the Player class now contains a number of mutator behaviors. Following convention, the names of these behaviors begin with the word Set.

In a class diagram, the format for a setter behavior(subroutine) looks like this:

Visibility SubroutineName(Parameters: DataType)

...as can be seen in the Player class example:

+SetName(NewName: String)

The implementation (code) for a mutator, reads the parameter that is passed to it and updates the value of the state with the value of the parameter. In other words, the SetName() function will read the String parameter passed to it and then change the value of the Name state.

An mutator behavior has visibility of Public.

Naming Conventions

Variables are prededed by a prefix to indicate the data type of the item. This method is known as a naming convention and improves the readability of your code. It is very similar to the way presentation objects from the toolbox are named.

Name prefixes for the following data types:
  • String - str
  • Integer - int
  • Boolean - bln
  • Decimal - dec

Wednesday, October 6, 2010

Coding Standards for Visual Basic

"The purpose of this document is to provide quality guidelines for the control of code developed in Visual Basic, ensuring some degree of discipline is employed in the development environment. In addition these standards are designed to increase readability, maintainability, reliability and portability of Visual Basic programs...."

http://www.pbdr.com/vbstd/VB%20Coding%20Standards%281%29.htm

Capitalization Styles/Naming Conventions

There are 3 conventions for naming styles.

Pascal case - backColor
Camel case - BackColor
Uppercase - IO,UI (for identifiers with short names)