Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

Operations

An operation is something that a class can do, or that you (or another class) can do to a class. Like an attribute-name, an operation's name is all in lowercase if it's one word. If the name consists of more than one word, join the words and begin all words after the first with an uppercase letter. The list of operations begins below a line that separates the operations from the attributes, as in Figure 3.7.

Figure 3.7 The list of a class's operations appears below a line that separates them from the class's attributes.

Just as you can indicate additional information for attributes, you can indicate additional information for operations. In the parentheses that follow an operation name, you can show the parameter that the operation works on, along with that parameter's type. One kind of operation, the function, returns a value after it finishes doing its work. For a function, you can show the value it returns and that value's type.

These pieces of information about an operation are called the operation's signature. Figure 3.8 shows how you represent the signature.

Figure 3.8 The signature for an operation.

  • + Share This
  • 🔖 Save To Your Account