Chapter 3 Building Structural Diagrams
Creating a standard operation
You can create the following types of standard operations:
- Default Constructor/Destructor Operations - A constructor is a special type of operation that can be added after creation and initialization of a class instance. A destructor can be added to de-initialize and destroy a class instance. You create constructors and destructors from the Operations tab of the class property sheet.
Depending on the object language of the OOM, you can create a Default constructor (Default means that the operation has no parameter), and a destructor for a class. For example, in C++ and PowerBuilder, you can create a constructor and a destructor, whereas in Java, you can only create a constructor.
If you want to add parameters to a constructor, you have to create a Default constructor using the following steps, and then add the parameters of your choice.
- Copy Constructor Operations - While a constructor creates and initializes an instance of a class, a Copy constructor makes a copy of the attributes of a class instance to initialize another instance.
When you create a Copy constructor, it has the same name as the class. It has a default parameter, prefixed by the keyword old, which you can modify, or you can add other parameters. If the class is a parent of another class, the attribute names within the body of the Copy constructor operation are the same as those in the parent class. You can define only one Copy constructor for any given class.
- Initializer or Static Initializer Operations (Java only) - The initializer and static initializer are blocks of code whose purpose is class initialization. They are executed before the class constructor and are handled as specific methods prefixed with the names: _INITIALIZER and _STATIC_INITIALIZER. The names and codes of the initializer and static initializer methods are read-only, and they do no have any parameters.
- Duplicate Operations - a duplicate operation is an operation that creates and initializes an instance of a class within the class. When you create a duplicate operation, it has the name Duplicate which you can modify. You can define only one duplicate operation for any given class.
- Activate/Deactivate Operations (PowerBuilder only)
To create a standard operation:
- Double-click a class in the diagram to open its property sheet, and then click the Operations tab.
- Click the Add button at the bottom of the tab, and select the type of standard operation you want to add. The operation is added to the list. Some or all of its properties will be dimmed to indicate that they are uneditable.
- Add other operations, or click OK to close the property sheet.
Copyright (C) 2006. Sybase Inc. All rights reserved.
|
|