![]() | MSc-IT Study Material January 2011 Edition Computer Science Department, University of Cape Town | MIT Notes Home | Edition Home | |
As the design progresses, classes can often be fit into various roles. Five common roles are presented below.
User interface classes. Instances of these classes are used to provide all the interaction between the user and the software. Often, interaction with the software occurs through the use of a metaphor (think of the desktop metaphor, or the drawing board metaphor in Computer Aided Design software), and user interface classes may represent elements of this metaphor.
Domain classes. These are the classes that are used to implement some specific portion of the problem domain that the software is attempting to solve. Classes that represent books and catalogues are examples of domain classes for software used in a library.
Process classes. Are lower-level domain classes used to implement the software.
Persistent classes. Are classes that represent data stores, and data that will persist even when the program is not executing. They are useful for hiding the details of obtaining specific data from databases and files.
System classes. Provide the functionality the software requires to operate and communicate with the environment in which it will be functioning.
When used in software design, these classes can be represented using appropriately named stereotypes. For example, user interface classes can be represented in class diagrams using the «user interface» stereotype, persistence classes with «persistent», and system classes with «system». However, the stereotypes should only be used if they will add useful meaning to the model. If knowing that a particular class will be used in the user interface is not useful, do not add the stereotype.
These classes should have the following properties:
The class should do all that its name implies, and do only what its name implies.
The class and each of its method should provide only one way to do the same thing.
The class should be functionally independent. That is, it should have high cohesion and low coupling.