29.11.2014 Views

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6. Verify that access paths exist for likely queries.<br />

7. Iterate <strong><strong>an</strong>d</strong> refine the model.<br />

8. Group classes into modules.<br />

However, you should not take the sequence of these steps too strictly: remember <strong>an</strong>alysis <strong><strong>an</strong>d</strong> design<br />

are rarely completed in a truly linear m<strong>an</strong>ner. It is likely that some steps will be performed to greater<br />

depths as the whole process proceeds. In addition, so me steps may (will) lead to revisions in other steps<br />

<strong><strong>an</strong>d</strong> once <strong>an</strong> initial design is produced it will doubtless require revisions. Therefore you should consider<br />

that they are a sequence of processes which should be performed. The order of which may be influenced<br />

by the domain, the expertise available, the application etc. However it is probably a good idea always to<br />

start with the process of identifying objects <strong><strong>an</strong>d</strong> classes.<br />

We will consider each of the above steps in more detail below.<br />

19.3.2.1 Identify objects <strong><strong>an</strong>d</strong> classes<br />

The first step in constructing the object model is to identify the objects in the domain <strong><strong>an</strong>d</strong> their classes.<br />

Such objects may include:<br />

• physical entities such as petrol pumps, engines <strong><strong>an</strong>d</strong> locks<br />

• logical entities such as employee records, purchases <strong><strong>an</strong>d</strong> speed<br />

• soft entities such as token, expression or data stream<br />

• conceptual entities such as needs, requirements or constraints.<br />

As long as they make sense for the application <strong><strong>an</strong>d</strong> the domain then they are a c<strong><strong>an</strong>d</strong>idate object or class.<br />

The only things you shoul d avoid are objects which might relate to the proposed computer<br />

implementation.<br />

OMT suggests that you start identifying these c<strong><strong>an</strong>d</strong>idate objects by looking in the textual problem<br />

description. It indicates that classes are often found by identifying nouns in the description <strong><strong>an</strong>d</strong> making<br />

them into classes. However, if you have a more formal problem specification it might be easier to<br />

identify a set of potential classes. If you have used the use case <strong>an</strong>alysis method you may also be able to<br />

identify the top most objects directly from the use case diagrams.<br />

Do not worry about getting it right at this point or about identifying classes which should not be<br />

there. Inappropriate classes will be filtered out later on - for the moment, attempt to find <strong>an</strong>ything which<br />

could be a class.<br />

Once you have a comprehensive list of c<strong><strong>an</strong>d</strong>idate classes you c<strong>an</strong> discard <strong>an</strong>y unnecessary <strong><strong>an</strong>d</strong><br />

incorrect ones. This is done by using the following criteria:<br />

Are <strong>an</strong>y of the classes redund<strong>an</strong>t ? That is, two or more classes express the same informat ion. For<br />

example, customer <strong><strong>an</strong>d</strong> user might just be different names for the same thing.<br />

Are <strong>an</strong>y of the classes irrelev<strong>an</strong>t ? That is, are they outside the scope of the system to be built even<br />

though they are part of the domain. For example, although porters wo rk in a hospital they are probably<br />

not relev<strong>an</strong>t to a hospital bed allocation system.<br />

Are <strong>an</strong>y of the classes vague ? That is, do they represent ill defined concepts? For example, history<br />

provision is vague - what is it a history of?<br />

Are <strong>an</strong>y of the classes really attributes of other classes? For example, name, address, salary, job title<br />

tend to be attributes of <strong>an</strong> object employee rather th<strong>an</strong> objects in their own right.<br />

This c<strong>an</strong> be a tricky one as it is often possible to represent something as both a class or a n attribute.<br />

One way of h<strong><strong>an</strong>d</strong>ling this is to leave the decision until later. If the class possesses only one type of<br />

information <strong><strong>an</strong>d</strong> has no operations then it should probably have been <strong>an</strong> attribute.<br />

Are <strong>an</strong>y of the classes really operations? If a class appears to describe <strong>an</strong> operation that is applied to<br />

objects <strong><strong>an</strong>d</strong> not m<strong>an</strong>ipulated in its own right then it is not a class. For example, a telephone call is a<br />

sequence of actions performed by a caller. In the implementation you may wish to make this <strong>an</strong> object,<br />

however at this point in the design we are trying to produce a model of the application domain (i.e. not<br />

<strong>an</strong> implementation model).<br />

Does the name of the class represent its intrinsic nature <strong><strong>an</strong>d</strong> not its role in the application ? For<br />

example, the class Person mig ht represent <strong>an</strong> object in a restaur<strong>an</strong>t booking system, but the class<br />

Customer is a better representation of its role in the system.<br />

Is a class really <strong>an</strong> implementation construct ? For example, things such as process, algorithm,<br />

interrupt, exception are implementation concepts <strong><strong>an</strong>d</strong> tend not to be related to the application domain.<br />

158

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!