Nouns and Verb

Here are the steps. It seems pretty complicated at first, but it is logical. Once you get the hang of it, it won't seem so hard!

Learning the process makes much of your class design and implementation "no-brainer". This frees up your brain to work on the parts that really are difficult and you can usually re-use the code you've already written and tested.

Later, you may find a method that works better for you, but learn this one first before you try to use your own.

At each step, if you can't think of anything more, or aren't clear what to do, skip it and go back to it later. In other words, don't let yourself get stuck. If it's not essential, skip it! Also, try to make your design match the way people think about it in real life.

Ok, enough pep talk - let's get started!


Write down all the nouns. Don't analyze them, this step is more like brainstorming!

  1. Analyze the nouns. Look for the classes and data members (C++) or instance variables (Java). Start with 1 class.

    Double check it with hasa - a class hasa data member.

    If it's not clear, skip it for now!

  2. Start coding the class declaration (the .h file or the .java file)

    1. Fill in the class name.
    2. Fill in the data member/instance variable names (make them private and pick good names for the identifiers).
    3. Determine the classes for the data members/instance variables.

  3. Next, write the prototypes for the access functions. They should be public. As a good rule of thumb, write an access function for each data member.

    Write the code for the methods (in the .cpp file or the .java file). A typical access function just returns the data member/instance variable.

  4. Now is time for more thinking - write the prototypes for the constructors. As a minimum, write the default constructor.

Ok, time for a small test program! Make sure you test every constructor and every access function. Fix any errors before going on.


Next are the "in-between" steps:

  1. Every object should be able to display itself. You should write a function that displays the object in a nicely formatted form. Typically you will print the value for each data member.

    A good name for this member function would be print() or trace().

  2. In Java, every class should have a toString() - it returns a string version showing the values of the attributes.

  3. Write a set() function for each data member (if it makes sense).

Now, time for more testing! Make sure it's perfect before you go on!

The goal is that by working on the nouns first you have worked out many of the details of how your class should work and maybe even done most of the work (and tested it) already.


Ok, time to do the verbs - usually the hard part! Write down all the verbs (or verb phrases).

  1. Analyze the verbs - they become methods or member functions.

  2. Work on one method at a time. It usually works best to do the easiest ones first!
  3. For a graphical class in Java, you would typically write a method to draw (outline) or fill (filled-in). This method would take a Graphics object and use it for drawing.

  4. In any case, write the signature (in the .java file) or the member function prototype (in the .h) for either Java or C++.
  5. Write the code for the method in the .java or .cpp (for C++) file. Try to re-use your methods. Make sure you test as you go!

Finish up your main program. Don't forget your test plan and you're done!