Reusability Requirements


Description:

In order for a class to qualify as a modularized class and be placed in the library, it needs to meet a few reusability requirements:

  1. The class must not be a MIDlet, it should be a simple Java class. MIDlets should be the highest level class run on the SPOT. (AKA the StartApplication? class).
  1. The class must not have methods that never exit (if they're called from another class, what's the point?).
  1. The class *should* have at least one constructor (if it isn't a utility class). The more complex the class is, the more constructors you may need. Sometimes the default empty constructor is fine for some classes.
  1. The variables used in the class should all be private and accessed only by setter/getter methods. Whether or not a specific variable needs a getter/setter method should be decided based on whether or not a user would need to access them. If you believe that the class will someday be a parent class, then set whatever variables that you think the child class might use to protected rather than private.
  1. Internal methods used by the class for helping with other methods should be private. Methods that you wish to give the user access too should be public. If you believe that the class will someday be a parent class, then set whatever methods that you think the child class might use to protected rather than private.
  1. Most methods should have a return. Methods that have no return and have the ability to 'fail' in their operation should return a boolean whose value will depend on whether the method succeeded or not. Setter methods do not need returns and many utility methods do not need returns.
  1. Most obviously, the decision should be made whether or not the class WILL be reused. Code to make a SPOTBot move in a square obviously would not be something to put in a library. If the decision is questionable, ask someone else their opinion and decide based on their input.

See also:

The SPOTBot Wiki Home

SourceCode