Unit 5 Flashcards
(41 cards)
Why do object modellers concentrate on nouns?
The nouns represent the things in the domain being modelled, and things are more stable than actions, which are expressed as verbs.
What are the main criteria for filtering a list of nouns in order to remove inappropriate ones and settle upon a more suitable set of candidate classes?
There are three basic criteria that can be applied as follows:
Redundancy;
Not important or independent enough, such as an attribute of another class rather than a class in its own right;
Lack of relevance to the problem domain; either beyond the scope of the desired system, or part of the language used for modelling.
Explain why object diagrams cannot form the basis for a software specification.
Object diagrams represent particular states of the system at particular moments in time, whereas a specification must describe all valid states of the system, at all possible times.
In a windowing system, a window may be converted to an icon, and back to a full window. What operations can be performed on full windows but not on iconised windows? Would a model containing the classes Icon and FullWindow be able to capture the distinction adequately?
Scrolling and maximising can be done on full windows but not on iconised ones. It will be difficult to model the distinction between a full window and its iconised version adequately by using two different classes, since an object (in this case, the window) cannot dynamically change its class. A solution to this problem might be to have a single class in which an attribute makes the distinction.
In connection with rooms, the hotel manager’s vocabulary includes the words ‘occupied’ and ‘free’. How might such words be represented in a class diagram?
Two ways come immediately to mind: c as an attribute of the Room class; c as an association between the Room and Guest classes. Either is quite acceptable as a way of recording the information.
In your model in part (b), will your decision about occupancy change if you have to include the fact that a room must be cleaned before the next guest occupies it?
No. The cleaning of a room certainly depends upon whether or not it is occupied, but not on how we choose to model occupancy. (You would include this requirement relating to cleaning in a dynamic model, such as a sequence diagram or state diagram. This will be discussed in a later unit.)
Does invoking an operation on an instance of a class always change the object’s state?
No. Not all operations are intended to change an object’s state. For example, you might provide an operation on the Guest class to respond with the address for any particular instance (object) of that class.
What does an attribute of a class represent?
An attribute represents a particular property (a named value) of the class that each instance of that class will have. Whatever else the attributes of a class are used for, at any one time they collectively define the state of an instance of the class.
Does a multiplicity of 1 indicate that there can be no change in the object to which the multiplicity relates?
No. It merely means that at any one time there will be exactly one object at that end of the relationship. The attributes, or even the identity, of this object may change over time.
If an airline system models flights and pilots, and each flight needs two pilots, would you use a multiplicity of 2?
Probably not. There are probably times during the life of a Flight object when fewer than two pilots are allocated, such as when the flight has been scheduled but crew details have not yet been settled.
Suppose that each person has a number of wardrobes, and each wardrobe contains an even number of shoes. How would you model the evenness of the shoes?
You might use a multiplicity on the association between the classes Wardrobe and Shoe, indicating that valid values were 0, 2, 4, 6, 8 and so on up to some reasonable limit. Alternatively, you could say that a Wardrobe contains an arbitrary number of instances of a class called ShoePair, where each ShoePair contains one left shoe and one right shoe. This approach generalises more easily to situations where the groups are not homogeneous. For example, a table setting contains one knife, one fork and one spoon.
If a model contains role names, do you also need to use association names?
No, but it is sometimes convenient to have a name for the association as a whole. For example, you might focus on what is meant by works for, rather than the need to consider both the role employer and the role employee (at the same time).
What is a navigation expression used for?
It provides a way of naming another object or its attributes relative to a starting object, by referring to intermediate role names.
What is a recursive association?
A recursive association is an association where both ends terminate at the same class.
Imagine you are drawing up the specification for a software system for a petrol station to administer the dispensing of petrol and its associated billing. Consider all the interactions that are involved between driving into the petrol station and departing. What makes the petrol flow? How does the cashier know how much to charge? How does the manager know when to refill the storage tanks? Make a list of all the nouns that you use in describing how various people make use of the system. (You are not required to make judgements about relevance or implementation at this stage.) After you have done that, filter your list of candidate classes. You need to be clear about the reasons for rejecting them.
Here is our list, but yours may be different.
arrival,
bill,car,car’s petrol tank,cashier,change, cheque, credit card, customer, delivered volume, departure, fuel cost, fuel delivery, fuel quantity sold, fuel type, holster, manager, nozzle, petrol tank, cap, price display, pump,sale, signature, storage tank for fuel,
trigger, unit fuel cost, volume display.
You can group the rejected nouns from our candidate class list using the following
reasons:
Out of scope – customer, cashier, petrol tank cap, cheque and signature;
Probably out of scope – change and credit card;
An operation – sale, arrival, departure and fuel delivery;
Attributes of something else – car’s petrol tank, unit fuel cost and fuel type.
In Figure 1, suppose that Jack checks out of the hotel. What changes would you make to the diagram?
The link between jack and room r123 should be deleted. Whether or not the link between jack and theRitz should be removed needs to be checked with the domain expert, because the hotel may wish to retain some link with its guests after they have checked out.
Give examples of different possible interpretations of classes with the names Room and Guest. When would new instances be created, and when would they be destroyed?
A Room class might represent physical rooms, which might be created and destroyed as building operations change the number of physical rooms. The instances might represent lettable rooms, whose existence might be related to whether the room was unlettable because of cleaning or repair works. A Guest class could represent a person currently staying in the hotel, which would be created at check in and destroyed at check out. It might represent a person who has stayed at least once, so that they would be created on the first check in and not destroyed on check out, but kept on the books. It might represent a potential guest, such as someone who has reserved but perhaps did not stay. Instances would be created on first contact with the hotel, and perhaps would not be destroyed, or not until they had generated no business for some years.
Figure 16 presents a preliminary model for a software system to assist with the administration of a number of orchestras. Study the model and make a list of possible problem areas that would need to be resolved with the domain experts – presumably the orchestra managers.
You may have identified other problem areas, but here are nine that we found using some domain knowledge.
1 A player can play for only one orchestra.
2 The model cannot represent an orchestra that currently has no players, such as
during the gap between forming the orchestra and hiring the first player.
3 Is there always a ‘next concert’ – even immediately after a new orchestra has been
created?
4 Does any player ever play multiple instruments?
5 What does ‘instrument’ mean? Does it refer to an instrument type, such as a violin,
or to a particular instrument, such as Susan’s Stradivarius violin? If it means the latter, do we need the concept of ‘instrument type’?
6 The model currently just shows that pieces of music need instruments. Do you
need to say how many of each instrument will be needed?
7 Does a single orchestra give each concert?
8 Is there only one conductor associated with an orchestra? Do you need to distinguish chief conductors from guest conductors? Should Concert have an association with conductors?
9 What is meant by ‘piece’? How many times can an orchestra play each piece?
Build a model to show the relationships between a person and their natural parents. Does your model prohibit someone from being his or her own mother? Is your model true for the whole of humanity or just for the people represented in some software system?
Figure 17 shows one possible model. There is nothing to say that the people at the end of the relationships are different. Since the non-identity of parent and child is part of the meaning of being a parent, you will need to capture that constraint in some other way. We have shown that every person has a father and a mother. That is true if we include dead people as instances of Person, but is not true if Person represents a living person, or a person in some finite set such as those represented in a computer. This is another example of how vital a project glossary is to relate terms in the class model, such as Person, to one particular meaning in the world. Simply naming a class Person is never enough.
When considering attributes, what is the effect of moving from a conceptual model to a specification model?
The conceptual model records attributes of classes that will be familiar to a domain expert. For example, a hotel manager will be familiar with the daily rate for a room and whether or not it is occupied. In the specification model, the developer must consider the representation of attributes within a software system. For instance, daily rates for rooms involve money, and you can use a true/false (Boolean) expression to represent the occupancy of rooms.
Why is a class model not sufficient to describe a system?
A class model is a static model that describes the elements of a system (the classes) and their relationships (the associations), but does not describe the behaviour of the system over time. For this you will need one or more dynamic models. In particular, you need to model the life histories of objects and the interactions between them. The model needs to capture when instances of classes should be created and destroyed.
What is meant by navigability? When is this idea useful?
Navigability means that it is possible to identify (or ‘reach’) objects in one class from objects in an associated class. The usefulness of this idea is realised during implementation when navigability in one direction alone (unidirectional navigability) can lead to simpler code.
In a multi-user operating system, users are allocated passwords. Draw a fragment of a class model to represent this association. Bear in mind that you do not want to be able to identify the corresponding user for a given password. What does this tell you about the representation of the association?
Users will want to ‘know about’ their passwords, not the other way round. Figure 23 shows that each instance of the class User will have a collection of references to the appropriate Password objects.
What is a qualified association?
A qualified association is an association at one end of which there is a qualifier, consisting of one or more attributes. The values of the attributes (taken together) uniquely identify the objects in the class at the other end of the association.