Designing Software  «Prev 

Choosing a Design Pattern

One of the key distinctions between Alexander's architectural patterns and software design patterns is that software patterns encourage reuse and modification of both
  1. objects and
  2. classes.

Architectural patterns primarily encourage reuse of blueprints, that is classes, but not of the actual buildings, parks, and towns built from those blueprints. It is much easier to tear down and replace part of a software package as needed than it is to extend a house.

The State Pattern seems like a great idea. It lets me change an object state dynamically.
However, not all states have the same methods. Administrators have more methods than User. Moderator does not have any of the methods from Admin or User. You can only use General to log in. I think that this will then limit the ability to use State Pattern.
Do you have any suggestions for some other pattern?

Object Hierarchies and Design Patterns

There is more to object-oriented programming than simply encapsulating in an object some data and the procedures for manipulating those data. Object-oriented methods deal also with the classification of objects and they address the relationships between different classes of objects. The primary facility for expressing relationships between classes of objects is derivation-, which is the process of creating new classes can be derived from existing classes.
What makes derivation so useful is the notion of inheritance. Derived classes inherit the characteristics of the classes from which they are derived. In addition, inherited functionality can be overridden and additional functionality can be defined in a derived class. A feature of this book is that virtually all the data structures are presented in the context of a single class hierarchy. In effect, the class hierarchy is a taxonomy of data structures. Different implementations of a given abstract data structure are all derived from the same abstract base class. Related base classes are in turn derived from classes that abstract and encapsulate the common features of those classes. In addition to dealing with hierarchically related classes, experienced object-oriented designers also consider very carefully the interactions between unrelated classes. With experience, a good designer discovers the recurring patterns of interactions between objects. By learning to use these patterns, your object-oriented designs will become more flexible and reusable. Recently, programmers have to started name the common design patterns. In addition, catalogs of the common patterns are now being compiled and published
The following object-oriented design patterns are used throughout this text:
  1. Containers
  2. Enumerators
  3. Visitors
  4. Cursors
  5. Adapters