Summary of Nouns and Verbs
Here is a summary of the steps we just learned:
- Write down all the nouns and nouns phrases.
- Analize the nouns. Look for the classes and data members.
If it's not clear, skip it for now!
- Pick one class to work on at a time.
- Brainstorm on nouns again related to the class you have chosen to work
on at a time. Double check your instance variables with "hasa".
- Start coding the class. Use the class name, followed by a .java
extension for your source file.
- Type in the class name.
- Type in the instance variable names. Make them private.
- Determine the classes for the data members and type that in.
- Next, design and write the signatures for the access methods. Make them
public. As a good rule of thumb, write an access function for each
Then, write the code for the methods. An access method typically just returns
the instance variable.
- Now analyze the class to determine the constructors.
Design the signatures for the constructors. As a minumum, start with the default
constructor. Write the code for the constructor(s).
- Write your test program to start testing your class.
Make sure you test every constructor and every access function.
Fix any errors before going on. As you think of additional instance variables,
constructors or other methods related to accessing the instance variables,
design, code, and test them.
- Design and write set-methods that allow the object to be changed. A good
rule of thumb is to write one that takes a value for each instance variable and
also write an additional one for setting each individual value separately.
Only write the ones that make sense. Test them before going on.
- Every object should be able to display itself, so write the toString()
method and a print method that prints the values of the object to System.out.
Test these thoroughly before continuing.
- If it makes sense for the object to display itself graphically, write a
paint() method that draw the object. Test it.
- Design, write, and test any other methods related to setting or
displaying the object before continuing to the full-blown verb analysis.
- Write down all the verbs and verb phrases that you have not already
taken care of.
- Analyze the verbs and determine the behaviors that should be encapsulated
in your class. Concentrate on only the most essential ones.
- Design and code the most essential method that is the simplest. Try to
re-use the methods you have already written. Test it thoroughly.
- Do each verb on at a time - design, code, and test each method before
working on the next one.
- Make sure your class passes your test plan.
After your class has been thoroughly tested, start working on the program
(application or Applet) that uses the class.