Object-Oriented Analysis and Design

As discussed previously, object-oriented programming has been around since the 1990s. Formal design processes when using objects involves many complex stages and are the debate of much research and development.

Why use the object-oriented approach?

Consider the general cycle that a programmer goes through to solve a programming problem:

  • Formulate the problem - The programmer must completely understand the problem.

  • Analyse the problem - The programmer must find the important concepts of the problem.

  • Design - The programmer must design a solution based on the analysis.

  • Code - Finally the programmer writes the code to implement the design.

The Waterfall Model

The Waterfall Model[1] as shown in Figure 1.13, “The Waterfall Model” is a linear sequential model that begins with definition and ends with system operation and maintenance. It is the most common software development life cycle model and is particularly useful when specifying overview project plans as it fits neatly into a Gantt chart format[2].

Figure 1.13. The Waterfall Model

The Waterfall Model

The seven phases in the process as shown in Figure 1.13, “The Waterfall Model” are:

  • Requirements Definition: The customer must define the requirements to allow the developer to understand what is required of the software system. If this development is part of a larger system then other development teams must communicate to develop system interfaces.

  • Analysis:The requirements must be analysed to form the initial software system model.

  • Design: The design stage involves the detailed definition of inputs, outputs and processing required of the components of the software system model.

  • Coding: The design is now coded, requiring quality assurance of inspection, unit testing and integration testing.

  • System Tests: Once the coding phase is complete, system tests are performed to locate as many software errors as possible. This is carried out by developer before the software is passed to the client. The client may carry out further tests or carry out joint tests with the developer.

  • Installation and Conversion: The software system is installed, and as part of a larger system it may be an upgrade, in which case further testing may be required to ensure that the conversion to the upgrade does not effect the regular corporate activity.

  • Operation and Maintenance: Software operation begins once it is installed on the client site. Maintenance will be required over the life of the software system once it is installed - This maintenance could be repair, to fix a fault identified by the client, adaptive to use the current system features to fulfil new requirements or perfective to add new features to improve performance or functionality.

The Waterfall Model is a general model, where in small projects some of the phases can be dropped, whereas in large scale software development projects some of these phases may be split into further phases. At the end of each phase the outcome is evaluated and if approved development can progress to the next phase. If the evaluation is rejected then the last phase must be revisited and in some cases earlier phases may need to be examined. In Figure 1.13, “The Waterfall Model” the thicker line shows the likely path if all phases are going well. The thinner lines show a retrace of steps to the same phase or previous phases.

The Spiral Model

The Spiral Model[3] was suggested by Boehm (1988) as a methodology for overseeing large scale software development projects that show high prospects for failure. It is an iterative model that builds in risk analysis and formal client participation into prototype development. This model can be demonstrated as in Figure 1.14, “The Spiral Model”.

Figure 1.14. The Spiral Model

The Spiral Model

The spiral, as shown in Figure 1.14, “The Spiral Model” of development is iterative, with each iteration involving planning, risk analysis, engineering (from design, to coding, testing, installation and then release) and customer evaluation (including comments, changes and further requirements). More advanced forms of this model are available for dealing with further communication with the client.

The spiral model is particulary suited to large scale software development projects and needs constant review. For smaller projects an agile development model is more suitable (discussed later).

The Object-Oriented Design Model

One object-oriented methodology is based around the re-use of development modules and components. As such, a new development model is required that takes this re-use into account. The object-oriented model as shown in Figure 1.15, “The Object-Oriented Design Model” builds integration of existing software modules into the system development. A database of reusable components supplies the components for re-use. The object-oriented model starts with the formulation and analysis of the problem. The design phase is followed by a survey of the component library to see if any of the components can be re-used in the system development. If the component is not available in the library then a new component must be developed, involving formulation, analysis, coding and testing of the module. The new component is added to the library and used to construct the new application.

This model aims to reduce costs by integrating existing modules into development. These modules are usually of a higher quality as they have been tested in the field by other clients and should have been debugged. The development time using this model should be lower as there is less code to write.

Figure 1.15. The Object-Oriented Design Model

The Object-Oriented Design Model

The object-oriented model should provide advantages over the other models as the libary of components grows over time.

An Example Design Problem

Task: If we were given the problem; “Write a program to implement a simple savings account”… The account should allow deposits, withdrawals, interest and fees.

Solution: The problem produces many concepts, such as bank account, deposit, withdrawal, balance etc.. that are important to understand. An OO language allows the programmer to bring these concepts right through to the coding step. The savings account may be built with the properties of an account number and balance and with the methods of deposit and withdrawal, in keeping with the concept of the bank account. This allows an almost direct mapping between the design and the coding stages, allowing code that is easy to read and understand (reducing maintenance and development costs).

OOP also allows software re-use! … The concept of this savings account should be understood, independent of the rest of the problem. This general savings account will certainly find re-use in some other financial problem.

So after discussion with the client, the following formulation could be achieved - Design a banking system that contains both teller and ATM interaction with the rules:

  • The cashiers and ATMs dispense cash.

  • The network is shared by numerous banks.

  • Each transaction will involve an account and documentation.

  • There are different types of bank accounts.

  • There are different kinds of transactions.

  • All banks use the same currency.

  • Foreign currency transactions are permitted.

  • ATMs and tellers require a cash card.

Step 1. Identify Possible Classes

  • ATM, cashier, cashier station, software, customer, cash.

  • banking network, bank.

  • transaction, transaction record.

  • account, deposit account, long term savings account, current account.

  • withdrawal, lodgement, cheque.

  • currency.

  • foreign currency, euro cheque.

  • cash card, computer system.

Step 2. Remove Vague Classes

  • software, computer system, cash.

Step 3. Add New classes that arise!

  • currency converter

Step 4. Create Associations

  • Banking Network (includes cashiers and ATMs)

  • Banks (holds accounts)

  • Account ( has a balance, a currency, a log of transactions)

  • Transaction (requires a cash card)

  • Lodgement (has an account number, an amount)

  • Withdrawal (has an account number, an amount)

  • Cheque ( is a withdrawal, has a payee, an amount)

  • Eurocheque (is a cheque, has a currency)

  • ATMs (accept cashcards, dispenses cash)

Step 5. Refine the Classes

Bank:

  • has a name

  • has accounts

  • has a base currency

  • has a sort code

Account:

  • has an owner

  • has a balance

  • has an account number

  • has a log of transactions

Deposit Account:

  • is an account

  • has a shared interest rate

Current Account:

  • is an account

  • has an overdraft limit

Transaction:

  • has an account

  • has a date

  • has a value

  • has a bank

  • has an account Number

  • has a number

Withdrawal:

  • is a transaction

Lodgement:

  • is a transaction

Cheque:

  • is a withdrawal

  • has a payee

EuroCheque:

  • is a cheque

  • has a currency

CurrencyConverter:

Step 6. Visual Representation of the Classes

Figure 1.16. The Bank class.

The Bank class.

Figure 1.17. The Account class.

The Account class.

Figure 1.18. The Transaction class.

The Transaction class.


[1] Boehm, B. W. (1981) Software Engineering Economics, Ch. 4 Prentice Hall, Upper Saddle River, NJ.

Royce, W. W. (1970) "Managing the development of large software systems: concepts and techniques", Proceedings of IEEE WESCON, August 1970.

[2] http://en.wikipedia.org/wiki/Gantt

[3] Boehm, B. W. (1988) "A spiral model of software development and enhancement", Computer, 21(5), 61-72.