Class has operations that manipulate its attributes and perform other operations on its objects. Operations are sometimes referred to as functions; can be applied onto its own objects only. May have return types. Operation names may be overloaded; parameters differentiating between them. Parameters have types and may have default values. Operations are applied to an object of a class by calling it from that object. Operations hold the services offered by the class; they form the interface of the class. Visibility and scope of operations in a class may be restricted as for attributes. Static operations are referred to as class-scope operations, as they apply to all the instances of the class. They may be called directly using class name and without creating any instances. Class-scope operations can access only class-scope attributes of the class. Class-scope operations carry out generic operations of the class e.g., creating objects, finding objects, etc.
Operation syntax:
visibility name (parameter-list): return type-exp {property-string} name: type-exp=default-value
Default values of parameters are as supplied in class definition.
Operations are implemented by methods; methods are NOT
operations. Operations are specified (in the documentation file)
using pre-conditions, post-conditions, algorithms,
and effects on objects. Pre-conditions are conditions that must
be true before the operations can be applied. Post-conditions
are conditions that must be true after the operations has
been completed. Operation properties are documented in a file
which are accessible via tools. Persistent classes will have
their objects stored in files so that they may be accessed even after
the program has finished. Class-scope operations of a persistent
class performs the storing and retrieval of objects; such
operations may be: store(), load(), create()...
Persistent
class operations are shown by persistent tagged values.