This section contains 208 words (approx. 1 page at 300 words per page) |
An operation is an action or instruction that is performed on or by an object. A program consists of set of operations. A program can be compared to a process. A process consists of many steps. Let's use a laundry example. Mary is going to program her robot maid, Robbie to do the laundry. She would have to create operations or steps for Robbie.
These steps are:
- Open the laundry hamper.
- Place clothes in laundry basket
- Taking the clothes to the washing machine.
- Open the lid.
- Place clothes in the washing machine.
- Adding the laundry detergent to the washing machine.
- Closing the lid.
- Set the dial to the appropriate cycle.
- Turn the washing machine on.
- Remove clothes after washing cycle.
- Place clothes in dryer.
- Remove clothes after drying cycle.
- Fold clothes.
- Place clothes in closet.
In this example all of then operations are being performed on the clothes (the object). However, Robbie, the washing machine and dryer, which are also objects are performing actions.
Other names used for operations are method, message, functions or events. Examples of operations are jump, load, store, open and close. Functions are different because they do not change the object's state. Examples of functions would be add, subtract, multiply, divide and count.
This section contains 208 words (approx. 1 page at 300 words per page) |