A simplified OOD methodology can be expressed in the following steps:
1. Write down a detailed description of the problem.
2. Identify all (relevant) nouns and verbs.
3. From the list of nouns, select objects. Identify data components of each object.
4. From the list of verbs, select the operations.
In order to create objects you first need to create classes. To know what type of classes to create, you need to know what an object stores and what operations are needed to manipulate an object’s data. Because an object consists of data and operations on data in a single unit, in Java we use the mechanism of classes to combine data and its operations in a single unit. In OOD methodology, classes, data members of classes (known as fields), and operations are identified.
Teaching Tip
|
More information on Object-Oriented Design can be found at:
|
Implementing Classes and Operations
Once the relevant classes, data members of each class, and relevant operations for each class are identified, the next step is to implement these things in Java.
In Java, to implement operations we write algorithms. Since there is usually more than one operation on an object, each algorithm is implemented with the help of Java’s methods. However, Java does not provide all the methods that you will ever need. Therefore, to learn how to design and implement classes, you first must learn how to construct and implement your own methods.
No comments:
Post a Comment