Pattern: New Class


Context

In Smalltalk everything is an object, and all objects are instances of a class. Programming an Application in Smalltalk begins with the creation of one or more new classes. Having identified a taxonomy of classes, one needs to be able to define them in Dolphin.

Solution

  1. Consider the attributes and behaviour that the class will implement.
  2. Choose a Class Name name for the class.
  3. Decide where, in the existing class hierarchy, to position the new class. This may involve choosing between class inheritance and object composition. You may also wish to decide at this stage whether the class will be an Abstract Class or will be subclassed from one. The best default choice is to subclass Object which would provide a minimum set of inherited behaviour suitable for virtually all objects.
  4. Choose a set of Instance Variable Names to represent the state of the object.
  5. Use a Class Hierarchy Browser to create the class.
  6. Add a method or methods to perform any required Class Initialization for the new class.
  7. Add appropriate Instance Creation methods.
  8. Implement an Instance Initialization method if required
  9. Add appropriate Accessor Methods.
  10. Implement the behaviour of the class

Related Patterns