Monday, June 2, 2008

FINDING CANDIDATE CLASSES

Under the topic of finding classes from requirements document, the textual analysis method to find potential classes will be discussed. The candidate classes in the analysis model understandably come from the requirement specification. The text in the specification can be analysed to find potential classes. Generally, a noun in the requirement description corresponds to a potential class. Similarly, adjectives may represent attributes of these candidate classes where as verbs may represent methods of these candidate classes. When identifying these classes, it is important to note that, to model a given system domain, there is no single correct choice of classes. This choice depends on the person, his/her ability and experience. Since poorly chosen classes may add complexity to later phases of the development cycle, and could make the software difficult to maintain and/or extend. Also note that good choices are crucial to the software development process.

Textual analysis – A technique to identify potential classes from a requirements document

Since a class is conceptually a set of objects of the same kind, and objects represent ‘things’ in the system domain, nouns and noun phrases in the requirements document can be used as an aid to identify possible classes.

Example

Below is an extract from the requirements document for a DVD Library System with the nouns and noun phrases underlined.

  • The DVD Library holds DVDs of a number of films. It may have any number of copies of each film. The system should, for each film, hold the film's title; no two films have the same title.
  • A library member can borrow any DVD of a film that is not currently on loan. However, no member can have more than six DVDs on loan at once. A borrowed DVD must be returned within three days. When a library member returns a DVD it immediately becomes available for loan to other members.
  • Each DVD has a unique identifying number.
  • Each member of the library has a unique membership number; the system also holds each member's name.

Choosing the nouns and noun phrases is not an exact science. If we consider the nouns and noun phrases underlined in the above example we can identify some problems with the Textual analysis method.

  • Problem with noun phrases – If we consider the requirement, It may have any number of copies of each film, here the noun phrase is any number of copies of each film. But it is obvious that the whole noun phrase doesn’t directly relate to any potential class. That’s why in the above example, only the words, ‘number of copies’ and ‘film’ are undelined.
  • Nouns and noun phrases are duplicated – In the above example, the term DVD appears more than once.
  • Have to deal with different ways of referring to the same thing – in the above example both ‘member’ and ‘library member’ appear. Both refer to the same thing. Therefore instead of having two separate classes, ideally there should be only one class.
  • Same word may be used to refer to different things - in the above example, ‘number’ might represent the unique number of DVD or it might represent the unique number of member.

Therefore by grouping nouns that are synonyms we get the following list of candidate classes.

· library (also referred to as ‘DVD Library’)

· DVD (also referred to as ‘copy’)

· number of films

· number of copies

· film

· system (also referred to as ‘DVD Library System’)

· title (also referred to as ‘film title’)

· member (also referred to as ‘library member’)

· loan

· day

· identifying number

· membership number

· member's name

Note – Every item listed here will not give rise to appropriate classes. Your ability to select appropriate classes will improve with experience.

Guidelines for rejection of inappropriate candidate classes

The set of guidelines explained here can be used to reject improper candidate classes.

Is it a property? - In the DVD Library, the word title although it is a noun it is an attribute of a film. Therefore rather than modeling it as a separate class, it is appropriate to model it as an attribute of film class.

Does it refer to a behavior of the system? – Consider the requirement; ‘The system displays a list of the film titles and return dates for the DVDs borrowed by each member’. Here the word ‘list’ although it is a noun it is something that the system has to produce as part of its behavior. Therefore we don’t need to have a separate list class.

Is it outside the scope of the system? - The ‘library’ itself falls into this category. The system will operate in the context of the library and we need to consider only the entities that are inside the library. Here the library is the boundary of the system domain.

Does it refer to an aspect of the user interface? - Consider the requirement; ‘The librarian enters the unique identifying number of the DVD using a barcode reader’. Here ‘barcode reader’ is an aspect of user interface. Therefore we can omit such nouns.

Does it refer to connections between other significant entities in the system domain? - In the DVD Library, since loan is the connection between a DVD and the member who borrowed it, we can omit it from list of candidate classes and model it as an association. But in this example, loan has properties (ex- borrowed date) on its own. Therefore we have to model it as a separate class.

Is it a word or phrase that is used in talking about systems in general, rather than a reference to something in the system domain? Words such as ‘system’, ‘behaviour’ and ‘requirement’ fall into this category: they do not refer to entities in the system domain. Therefore we can omit such nouns.

Surangi N. Alexander (044052)

0 comments: