| Stephen R. Palmer | Software Development | www.step-10.com |
| Home | Design | Process | Tools | Books | About |
|
|
Modelling in Colour: Typical ResponsibilitiesClasses belonging to each of the particular class archetypes tend to have similar responsibilities. Therefore, for each class archetype we can build up a list of typical responsibilities. Once we have these lists we can use them as checklists for responsibilities of classes in our own problem domain object models. For example, if we know a Moment-Interval class typically has a responsibility to remember when the Moment-Interval occurred, when we create a new Moment-Interval class in our own problem domain object models we immediately know to ask what date and time information objects of the class need to hold. The checklists of typical responsibilities for the class archetypes help us clarify requirement details and may identify missing requirements. For example, if we have a Priority responsibility on our checklist for Moment-Interval classes we can ask domain experts and check requirement sources to see if we need that responsibility in any of the Moment-Interval classes in our own problem domain model. Responsibilities of the Moment-Interval class archetypeThe typical responsibilities of Moment-Interval classes include:
Responsibilities of the Role class archetypeThe typical responsibilities of Role classes include:
Responsibilities of the Party, Place, Thing class archetypeThe typical responsibilities of Party, Place, Thing classes include:
Responsibilities of the Description class archetypeThe typical responsibilities of Description classes include:
Rebecca Wirfs-Brock defines a software responsibility as an obligation to perform a task or know information [Wirfs-Brock]. Peter Coad used to talk about operations of a class being what objects of that class did, the attributes of a class being what objects of that class knew about themselves, and the associations of a class being who, in terms of other objects, objects of that class knew [Coad97]. In other words, the responsibilities of an object are eventually expressed as a combination of operations, attributes and associations defined for that type of object. So when we say that we notice similar responsibilities appearing in our object models we usually mean that similar kinds and mixtures of operations, attributes and associations are turning up again and again. It also means that when we say a class will typically have a certain responsibility, we imply that the class will typically need to have a certain set and mixture of operations attributes and associations. In practice, after building a few models, most people find it easier to remember the typical operations, attributes, associations of class archetypes than lists of responsibilities for each class archetype. Our checklists therefore become lists of typical operations, associations and attributes that act as reminders or placeholders for the typical responsibilities of each class archetype.
Common Class Level ResponsibilitiesThere are a couple of class-level responsibilities that are common regardless of which archetype a class belongs. They are:
Details of Common or Similar ResponsibilitiesIdentification/Authorisation Objects of any class archetype frequently need to be matched with the
artifacts that represent them in the real problem domain. Like the objects they describe, the individual categories represented by Description objects frequently have unique identification codes or numbers. They also often have names and longer textual descriptions to supplement the codes or id numbers. Descriptions frequently have two kinds of identification number, one that is set by an external standards body, regulatory agency, or manufacturer and one that is assigned internally within an organisation. These two types of identity number are analogous to the manufacturers' identifier and the catalogue entry number for a particular item within a product catalogue respectively. Therefore, we expect that classes belonging to our four archetypes will define one or more attributes with suitable accessor and modifier operations to implement their identification responsibility. For example, we would expect a Moment-Interval class to have some sort of referenceNumber attribute, a Role class to have some sort of assignedNumber attribute, a Party, Place, Thing class to have some sort of identityNumber, and a Description class to have both some sort of type attribute and some sort of itemNumber attribute to model external and internal identifying numbers respectively. We would also expect a Description class to have some sort of description attribute so its objects can hold a longer textual explanation of the category they are describing. More on identification responsibilities... Status Objects of both Moment-Interval and Role classes frequently have a responsibility
to remember which of a number of states or modes they are in at the current
time. At a minimum we expect some sort of status attribute and a number of
state-change operations such as complete() and cancel() to appear in many Moment-Interval
classes. Alternatively, we could end up with an implementation of the state
design pattern [GoF]. We, therefore, expect some sort of status attribute and some sort of isAvailable() operation to be required by many of our Role classes. AssessmentMoment-Interval classes are often related to other Moment-Interval classes that happen before or after them in time. Therefore objects of Moment-Interval classes are typically responsible for interacting with prior and subsequent Moment-Interval objects to assess their performance in some way. Operations called assessWRTPriorMI() and assessWRTNextMI() act as reminders for these responsibilities (WRT is short for with respect to). Originally these were called mi_assessWRTPrior() and MI_assessWRTNext(). However, the MI_ prefix contradicts most modern naming standards and conventions. I prefer to use the more conventional MI suffix for operations that remind us of responsibilities involving next and prior Moment-Intervals A Role class is also typically responsible for assessing the role player's performance across a set of Moment-Intervals in which they have participated. The set of Moment-Intervals over which the assessment is made is often those that have occurred within a particular time-period such as a week, month, quarter, or accounting year. We therefore expect to often need some sort of assessAcrossMIs() operations in our Role classes. A Party, Place, Thing class is also typically responsible for assessing the role player's performance across all the roles they play and expect some sort of assessAcrossRoles() operations in many of our Party, Place, and Thing classes. A Description class is also typically responsible for assessing the performance of the set of described objects as they play their different roles in various Moment-Intervals so some sort of assessAcrossPPTs() operations are likely to be needed in our Description classes. CollaborationMoment-Intervals are typically responsible for remembering who was involved and how, where, and with what when the Moment-Interval happened. Therefore, Moment-Intervals are typically required to collaborate with related Role classes and therefore we can expect associations between Moment-Interval classes and Role classes. A Role class is typically expected to know which Moment-Intervals the role-player has participated in that role. Therefore, we should expect to find some sort of listMI() operations in our Role class and associations between Role classes and related Moment-Interval classes. A Party, Place, and Thing object needs to know and manage the set of Roles
that it is playing. Therefore we can expect associations between Party, Place
and Thing classes and related Role classes. We can also expect associations
between Party, Place, and Thing classes and Description classes that provide
common, standard and default values and behaviour for objects of the Party,
Place, and Thing classes. Description objects typically need to know and the set of Party, Place, Thing objects that they are describing so we expect associations between Description classes and related Party, Place and Thing classes. FactoryMoment-Intervals are often responsible for creating objects of subsequent related Moment-Intervals. Typical Operations, Attributes and AssociationsThe typical responsibilities of each of the class archetypes leads us to the following lists of typical operations, attributes, and associations:
This table is not particularly easy to remember. It would be better if we had some more concise, graphical way of representing this information. Class Archetypes and UMLUML is the most popular industry standard for representing object-oriented
analysis and design ideas in graphical form. Therefore, if we are building problem
domain object models and want to use class archetypes, it is highly likely we
will want a way to indicate the class archetype of a class in UML. |
More on... |