OOA Analysis & Design

Analyzing a Problem and Designing a Solution

Topics covered:
Analyze a problem using object-oriented analysis (OOA).
Design classes for creating objects for an application.

Case Study: Requirements of Fabrikam, Inc

The requirements of the new order entry system at Fabrikam, Inc, are as
follows:

  • Online order entry for customers.
  • Online availability of items with prices according to current catalog.
  • Verification of the availability of items for online orders.
  • Verification of the payment.
  • Submission of the order to the warehouse.
  • Confirmation of the order to the customers by providing an order ID and
    telephone extension number of the CSR for orders placed on the phone.

Define Problem Domain

  1. Gather customer requirements.
  2. Determine the scope of the problem and write a statement of scope that
    briefly states what you want to achieve.
  3. Identify the objects that will interact to solve the problem.

Identifying Objects

The properties of an object are as follows:
Conceptual or Physical –
A customer account cannot be touched; therefore it is conceptual. An ATM can be
touched; therefore it is physical.
Attributes –
Size, name, shape, boolean, data type
Operations –
Activities that an object can perform, for example, setting a value, performing
a calculation, displaying a UI.

Cow

Additional Criteria for Recognizing an Object

Relevance to problem domain
Does the object exist within the boundaries of the problem domain?
Is the object required for the solution to be complete?
Is the object required as part of an interaction between a user and the
solution?
Some items in a problem domain can be attributes of objects or objects
themselves. For example, temperature can be an attribute of an object in a
medical system, or it can be an object in a scientific system that tracks
weather patterns.

Independent existence
Does the object need to exist independently rather than being an attribute of
another object?

Case Study: Identifying Objects for Fabrikam, Inc.

Objects in the problem domain for Fabrkikam:
Order
Shirt
Customer

Case Study: Identifying Object Attributes and Operations

Examples of Attributes:
Data: Order ID, customer ID
Another Object: Customer having an order would be defined as an attribute of the
customer object.

Case Study: Attribute References to Other Objects

An attribute can be a reference to another object, but the association may or
may not be necessary to solve the problem.
* You should use attribute and operation names that clearly describe the
attribute or operation.

Case Study: Attributes and Operations for Fabrikam, Inc

There will be different attributes and operations for the following three
objects:

Order Object:
Attributes: OrderID, date, *shirt(s), totalPrice, *Form of Payment, *CSR, status
Operations: calculate order id, calculate total price, add shirt to order,
remove shirt from order, submit the order

Shirt Object:
Attributes: shirtID, price, description, size, color code
Operations: calculate shirt id, display shirt information

Customer Object:
Attributes: customerID, name, address, phone, email address, *Order,
Operations: assign a customer ID

Case Study: Solution

Tables depicting a partial list of objects including most of there attributes
and operations, are displayed on the screen. Additional objects can include a
warehouse and a supplier.
* Although implied, not all attributes in the solution are specifically defined
in the case study. For example, the Payment Object has an
expiration date attribute used for a credit card expiration date.

Designing Classes and Creating Instances

A class or blueprint is defined for each object in a system after the objects
have been identified. The feature of an object created from a class are:
It has a specific state or value for every attribute in the class
It has the same attributes and operations as other objects created from the same
class.

In terms of Object Oriented Design, let's use the following example:
Window manufactures great a blueprint for every style of window they make. These
blueprints define a range of {colors: blue, green, black} and {styles: small,
medium, large} that can be selected when purchasing a window. The blueprints are
the basis for any number of windows, with any number of combinations of color
and style. In terms of object oriented design, each window is an object and the
generic blueprint (large/blue, small/black) is a class. Each object created
using the class is called an instance of a class. More specifically, each object
created from a class can have a specific state or value for each of the
attributes it possesses, but will have the same attributes and operations.
Class: The American Heritage Dictionary defines class to be "a group whose
members have certain attributes in common."

Classes and Objects

An example of classification in terms of OOAD is:
Whale is a class.
Blue whale is an object instance of the whale class.

Fabrikam Case Study: Classes and Objects

Class: A class defines an object. For example, the shirt class defines all
shirts to have a shirt ID, size, color code, description, and price.

Object: An object is a unique instance of a class, for example, a large blue
polo shirt costing $19.99 with shirt ID 2425-A.

Every class has a class that it originated from. In OOAD terminology, this
parent class is referred to as superclass. For example, a whale might have
originated from the superclass mammals.

Variables and Methods

Variable: A variable is a Java programming language
mechanism for holding data or representing an attribute.
Method: A method is a Java programming language mechanism for
performing an operation.
* Variables also hold other data besides attribute data, such as values used
solely inside a method.

Modeling Classes

The first phase of the design stage consists of visually organizing or
modeling a program and its classes. To model a program and its classes, use the
following rules:
Each class in a design must be enclosed in a box, with the class name on top.
The class name must be followed by a list of attribute variables.
Attribute variables must be followed by method names.
Example:
ClassName
attributeVariableName [range of value]
attributeVariableName [range of value]
attributeVariableName [range of value]

methodName()
methodName()
methodName()

OR:
ShirtClass
shirtID
price
description
size
colorCode R=Red, B=Blue, G=Green

calculateShirtID()
displayShirtInformation()

* Modeling classes is similar to modeling database structures. In fact, your
objects can be stored in a database using the Java Database Connectivity (JDBC)
API. The JDBC API allows you to read and write records using structured query
language (SQL) statements within your Java technology programs.

0
  Related Posts