OOPS - Object Oriented Design, Study notes of Object Oriented Programming

This document about Object Oriented Design, The Interactive Intelligent Kitchen Helper, Working through scenarios, Identification of components, CRC Cards – Recording Responsibility, Documentation.

Typology: Study notes

2010/2011

Uploaded on 09/05/2011

vrunda
vrunda 🇮🇳

4.1

(21)

76 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Object Oriented Design
The Interactive Intelligent Kitchen Helper
The interactive Intelligent Kitchen Helper (IIKH) is a PC-based application that will
replace the index-card system of recipes found in the average kitchen. But more than
simply maintaining a database of recipes, the kitchen helper assists in the planning of
meals for an extended period – say, a week. The user of the IIKH can sit down at a
terminal, browse the database of recipes, and interactively create a series of menus. The
IIKH will automatically scale the recipes to any number of servings and will print out
menus for the entire week, for a particular day, or for a particular meal. It will also print
an integrated grocery list of all the items needed for the recipes for the entire period.
The fundamental cornerstone of object-oriented programming is to characterize software
in terms of behavior-that is, actions to be performed. Initially, the team will try to
characterize, at a very high level of abstraction, the behavior of the entire application.
This then leads to a description of the behavior of various software subsystems.
Working through scenarios
The design team first creates a number of scenarios. That is, the team acts out the running
of the application just as if it already possessed a working system. An example scenario is
shown below.
Alice Smith sits down at her computer and starts the IIKH. When the program begins, it
displays a graphical image of a recipe box and identifies itself as the IIKH, product of
IIKH incorporated. Alice presses the return button to begin.
In response to the key press, Alice is given a choice of a number of options. She elects to
browse the recipe index, looking for a recipe for salmon that she wishes to prepare for
dinner the next day. This brings up a new window in which an attractive picture of the
finished dish is displayed, along with the list of ingredients, preparation steps, and
expected preparation time.
She requests a printout of the recipe, and the output is spooled to her printer. Alice selects
“quit” from a program menu, and the application quits.
Identification of components
The engineering of a complex physical system, such as a building or an automobile
engine, is simplified by dividing the design into smaller units. So, too, the engineering of
software is simplified by the identification and development of software components. A
component is simply an abstract entity that can perform tasks that is, fulfill some
responsibilities. A component may ultimately be turned into a function, a structure or
class, or a collection of other components.
A component must have a small, well-defined set of responsibilities.
A component should interact with other components to the minimal extent
possible.
pf3
pf4
pf5

Partial preview of the text

Download OOPS - Object Oriented Design and more Study notes Object Oriented Programming in PDF only on Docsity!

Object Oriented Design

The Interactive Intelligent Kitchen Helper

The interactive Intelligent Kitchen Helper (IIKH) is a PC-based application that will replace the index-card system of recipes found in the average kitchen. But more than simply maintaining a database of recipes, the kitchen helper assists in the planning of meals for an extended period – say, a week. The user of the IIKH can sit down at a terminal, browse the database of recipes, and interactively create a series of menus. The IIKH will automatically scale the recipes to any number of servings and will print out menus for the entire week, for a particular day, or for a particular meal. It will also print an integrated grocery list of all the items needed for the recipes for the entire period.

The fundamental cornerstone of object-oriented programming is to characterize software in terms of behavior-that is, actions to be performed. Initially, the team will try to characterize, at a very high level of abstraction, the behavior of the entire application. This then leads to a description of the behavior of various software subsystems.

Working through scenarios

The design team first creates a number of scenarios. That is, the team acts out the running of the application just as if it already possessed a working system. An example scenario is shown below.

Alice Smith sits down at her computer and starts the IIKH. When the program begins, it displays a graphical image of a recipe box and identifies itself as the IIKH, product of IIKH incorporated. Alice presses the return button to begin. In response to the key press, Alice is given a choice of a number of options. She elects to browse the recipe index, looking for a recipe for salmon that she wishes to prepare for dinner the next day. This brings up a new window in which an attractive picture of the finished dish is displayed, along with the list of ingredients, preparation steps, and expected preparation time. She requests a printout of the recipe, and the output is spooled to her printer. Alice selects “quit” from a program menu, and the application quits.

Identification of components

The engineering of a complex physical system, such as a building or an automobile engine, is simplified by dividing the design into smaller units. So, too, the engineering of software is simplified by the identification and development of software components. A component is simply an abstract entity that can perform tasks that is, fulfill some responsibilities. A component may ultimately be turned into a function, a structure or class, or a collection of other components.

  • (^) A component must have a small, well-defined set of responsibilities.
  • A component should interact with other components to the minimal extent possible.

CRC Cards – Recording Responsibility

As the design team walks through the various scenarios they have created, they identify the components that will be performing certain tasks. Every activity that must take place is identified and assigned to some components a responsibility. As part of this process, it is often useful to represent components using small index cards. Written on the face of the card is the name of the software component, the responsibilities for the component, and the names of the other components with which the component must interact. Such cards are sometimes known as CRC (Component, Responsibility, Collaborator) cards and are associated with each software component. As responsibilities for the component are discovered, they are recorded on the face of the CRC card. While working through scenarios, it is useful to assign CRC cards to different members of the design team.

The what/who cycle The identification of components takes place during the process of imagining the execution of a working system. Often this proceeds as a cycle of what/who questions.

on the terminal screen. The user may be given the ability to annotate or change either

the list of ingredients or the instruction portion. Alternatively, the user may request a printed copy of the recipe. All of these actions are the responsibility of the recipe component. To add a new recipe, the database manager somehow decides in which category to place the new recipe, request the name of the new recipe, and then creates a new recipe component, permitting the user to edit this new blank entry.

Investigate the development of daily menu plans, which is the Plan Manager’s task, in some way the user can save existing plans. Thus, the Plan Manager can either be started by retrieving an already developed plan or by creating a new plan. In the latter case, the user is prompted for a list of dates for the plan. Each date is associated with a separate Date component. The Date component maintains a collection of meals as well as any other annotations provided by the user (birthday celebrations, anniversaries, reminders, and so on) It prints information on the display concerning the specified date. By some means the user can indicate a desire to print all the information concerning a specific date or choose to explore in more detail a specific meal. In the latter case, a control is passed to a Meal component. The Meal component displays information about the mal. The user can add or remove recipes from the meal or can instruct that information about the meal be printed. In order to discover new recipes, the user must be permitted at this point to browse the recipe database. Thus, the Meal component must interact with the recipe database component. Having walked through the various scenarios, the software design team eventually decides that all activities can be adequately handled by six components. The Greeter needs to communicate only with the Plan Manager and the Recipe Database components. The Plan Manager needs to communicate only with the Date component and the date agent only with the Meal component. The Meal component communicates with the Recipe manager, through this agent, with individual recipes.

Interaction diagrams

While the process may illustrate the static relationships between components, it is not very good for describing their dynamic interactions during the execution of a scenario. A better tool for this purpose is an interaction diagram. Figure shows the beginning of an interaction diagram for the interactive kitchen helper. In the diagram, time moves forward from the top to the bottom. Each component is represented by a labeled vertical line. A component sending a message to another component is represented by a horizontal arrow from one line to another. Similarly, a component returning control and perhaps a result value back to the caller is represented by an arrow.

An example interaction diagram

Greeter Database Recipe Planner

Message browse()