CIR 204 Object-Oriented Systems and Design Notes
CIR 204 Object-Oriented Systems and Design Notes
YEAR 2 SEMESTER 2
COURSE NOTES
1
Object technology emphasizes modeling the real world and provides us with the stronger
equivalence of the real world‘s entities (objects) than other methodologies.
Raising the level of abstraction to the point where application can be implemented in the
same terms as they are described.
Overview of the Unified Approach
The UA, based on methodologies by Booch, Rumbaugh, Jacobson, and others, tries to
combine the best practices, processes, and guidelines.
UA based on methodologies by Booch, Rumbaugh and Jacobson tries to combine the best
practices, processes and guidelines along with the object management groups in unified
modelling language.
UML is a set of notations and conventions used to describe and model an application.
UA utilizes the unified modeling language (UML) which is a set of notations and
conventions used to describe and model an application.
Object:
In object-oriented system, everything is an object: numbers, arrays, records, fields, files,
forms, an invoice, etc.
An Object is anything, real or abstract, about which we store data and those methods that
manipulate the data.
Conceptually, each object is responsible for itself.
A window object is responsible for things like opening, sizing, and closing itself.
Object-Oriented Approach
Object’s Attributes
Attributes represented by data type.
They describe objects states.
In the Car example the car‘s attributes are:
color, manufacturer, cost, owner, model, etc.
Object’s Methods
Methods define objects behavior and specify the way in which an Object‘s data are
manipulated.
In the Car example the car‘s methods are:
2
drive it, lock it, tow it, carry passenger in it.
Types of classes:
There are two main types of classes: Concrete classes and abstract classes.
Concrete classes: A concrete class is a class that can have both subclasses and class
instances. The implementation details of the methods in a concrete class are fully defined.
The definition of a concrete class starts with the keyword class followed by the class
name
Abstract classes: An abstract class is a class that can have subclasses but cannot have
class instances. The methods in an abstract class do not have implementation details. The
implementation details of these methods are included in the subclasses that inherit the
abstract class. The definition of an abatract class starts with the keywords abstract class
followed by the class name
Class Hierarchy
An object-oriented system organizes classes into subclass-super hierarchy.
At the top of the hierarchy are the most general classes and at the bottom are the most
specific
A subclass inherits all of the properties and methods (procedures) defined in its super
class.
Motor vehicle
3
Inheritance (programming by extension)
Inheritance is a relationship between classes where one class is the parent class of
another (derived) class.
Inheritance allows classes to share and reuse behaviors and attributes.
The real advantage of inheritance is that we can build upon what we already have and,
Reuse what we already have.
Vehicle
Car
Ford
Multiple Inheritances
OO systems permit a class to inherit from more than one super class.
This kind of inheritance is referred to as multiple inheritance.
For example utility vehicle inherent from Bus and Truck classes.
Motor vehicle
Utility vehicle
4
Encapsulation and Information Hiding
Possible operations
Public protocol
Private protocol
Data
Messages
Polymorphism:
Is a mechanism that enables different methods to have the same name but different
implementations.
During program execution, the different methods are differentiated by the method
signature (the method name and the number of arguments used during the method call)
Encapsulation:
Is the binding together of the components of a class to make the class self contained and
provide data hiding.
The components that are bound together are the data elements and the methods that are
used to manipulate the data.
Data abstraction:
Is a mechanism that enables a developer to pick the most important data items of a class
and ignore the rest during program development.
Abstraction enhances reusability of existing classes.
5
Method overloading:
Is the ability to create different methods with the same name but different definitions.
During program execution, each method performs its function according to its
implementation details.
Method overriding:
This is a mechanism that allows a method that was defined in a super class to be
redefined in a subclass.
The function of the method in the subclass will follow the new definition in the subclass.
Interface:
An interface is a structure in object oriented programming that is defined using the
keyword interface followed by the interface name.
An interface contains constants and abstract methods that do not have implementations.
An interface cannot operate on its own, instead, it is implemented within a class.
The implementation details of the abstract classes declared in the interface are defined in
the class that implements the interface.
An interface is also used by an object as a means to communicate with other external
objects.
Message:
Objects interact by exchanging messages.
Objects perform operations in response to messages.
A message is sent to another object through method call.
The message is composed of method name and parameter value.
6
Rather than focusing on the production of large amount of paper documents, the Unified
Process emphasizes the development and maintenance of models - semantically rich
representations of the software system under development.
The Rational Unified Process is a guide for how to effectively use the Unified Modeling
Language (UML).
The UML is an industry-standard language that allows clear communication of
requirements, architectures and designs.
The Rational Unified Process captures many of the best practices in modern software
development in a form that is suitable for a wide range of projects and organizations.
The Rational Unified Process describes how to effectively deploy commercially proven
approaches to software development for software development teams. These are called “best
practices” because they are observed to be commonly used in industry by successful
organizations. The six best practices include:
7
An iterative approach also makes it easier to accommodate tactical changes in
requirements, features or schedule
Manage Requirements
The Rational Unified Process describes how to elicit, organize, and document required
functionality and constraints; track and document tradeoffs and decisions; and easily
capture and communicate business requirements.
The notions of use case and scenarios proscribed in the process has proven to be an
excellent way to capture functional requirements and to ensure that these drive the
design, implementation and testing of software, making it more likely that the final
system fulfills the end user needs.
8
Quality assessment is built into the process, in all activities, involving all participants,
using objective measurements and criteria, and not treated as an afterthought or a separate
activity performed by a separate group.
The Unified process describes the object oriented system development process.
The process can be described in two dimensions, or along two axes:
The horizontal axis represents time and shows the dynamic aspect of the process
as it is enacted, and it is expressed in terms of cycles, phases, iterations, and
milestones.
The vertical axis represents the static aspect of the process: how it is described in
terms of activities, artifacts, workers and workflows.
9
The Iterative Model graph shows how the process is structured along two dimensions
Inception phase
Elaboration phase
Construction phase
Transition phase
Each phase is concluded with a well-defined milestone - a point in time at which certain critical
decisions must be made and therefore key goals must have been achieved
10
The phases and major milestones in the process
Inception Phase
During the inception phase, you establish the business case for the system and delimit the
project scope.
To accomplish this you must identify all external entities with which the system will
interact (actors) and define the nature of this interaction at a high-level.
This involves identifying all use cases and describing a few significant ones.
The business case includes success criteria, risk assessment, and estimate of the resources
needed, and a phase plan showing dates of major milestones.
The outcome of the inception phase is:
A vision document: a general vision of the core project's requirements, key features, and
main constraints.
An initial use-case model (10% -20%) complete.
An initial project glossary (may optionally be partially expressed as a domain model).
An initial business case, which includes business context, success criteria (revenue
projection, market recognition, and so on), and financial forecast.
An initial risk assessment.
A project plan, showing phases and iterations.
A business model, if necessary.
One or several prototypes.
At the end of the inception phase is the first major project milestone: the Lifecycle Objectives
Milestone.
The evaluation criteria for the inception phase are:
Stakeholder concurrence on scope definition and cost/schedule estimates.
Requirements understanding as evidenced by the fidelity of the primary use cases.
11
Credibility of the cost/schedule estimates, priorities, risks, and development process.
Depth and breadth of any architectural prototype that was developed.
Actual expenditures versus planned expenditures.
The project may be cancelled or considerably re-thought if it fails to pass this milestone.
Elaboration Phase
The purpose of the elaboration phase is to analyze the problem domain, establish a sound
architectural foundation, develop the project plan, and eliminate the highest risk elements
of the project.
Architectural decisions have to be made with an understanding of the whole system: its
scope, major functionality and nonfunctional requirements such as performance
requirements.
At the end of this phase, the decision on whether or not to commit to the construction and
transition phases is made.
While the process must always accommodate changes, the elaboration phase activities
ensure that the architecture, requirements and plans are stable enough, and the risks are
sufficiently mitigated, so you can predictably determine the cost and schedule for the
completion of the development.
Conceptually, this level of fidelity would correspond to the level necessary for an
organization to commit to a fixed-price construction phase.
In the elaboration phase, an executable architecture prototype is built in one or more
iterations, depending on the scope, size, risk, and novelty of the project.
This effort should at least address the critical use cases identified in the inception phase,
which typically expose the major technical risks of the project.
While an evolutionary prototype of a production-quality component is always the goal,
this does not exclude the development of one or more exploratory, throwaway prototypes
to mitigate specific risks such as design/requirements trade-offs, component feasibility
study, or demonstrations to investors, customers, and end-users.
The outcome of the elaboration phase is:
A use-case model (at least 80% complete) — all use cases and actors have been
identified, and most use case descriptions have been developed.
Supplementary requirements capturing the non functional requirements and any
requirements that are not associated with a specific use case.
A Software Architecture Description.
An executable architectural prototype.
A revised risk list and a revised business case.
A development plan for the overall project, including the coarse-grained project plan,
showing iterations” and evaluation criteria for each iteration.
An updated development case specifying the process to be used.
12
A preliminary user manual (optional).
At the end of the elaboration phase is the second important project milestone, the
Lifecycle Architecture Milestone.
At this point, you examine the detailed system objectives and scope, the choice of
architecture, and the resolution of the major risks.
The main evaluation criteria for the elaboration phase involve the answers to these questions:
Is the vision of the product stable?
Is the architecture stable?
Does the executable demonstration show that the major risk elements have been
addressed and credibly resolved?
Is the plan for the construction phase sufficiently detailed and accurate? Is it backed up
with a credible basis of estimates?
Do all stakeholders agree that the current vision can be achieved if the current plan is
executed to develop the complete system, in the context of the current architecture?
Is the actual resource expenditure versus planned expenditure acceptable?
The project may be aborted or considerably re-thought if it fails to pass this milestone.
Construction Phase
During the construction phase, all remaining components and application features are
developed and integrated into the product, and all features are thoroughly tested.
The construction phase is, in one sense, a manufacturing process where emphasis is
placed on managing resources and controlling operations to optimize costs, schedules,
and quality.
In this sense, the management mindset undergoes a transition from the development of
intellectual property during inception and elaboration, to the development of deployable
products during construction and transition.
Many projects are large enough that parallel construction increments can be spawned.
These parallel activities can significantly accelerate the availability of deployable
releases; they can also increase the complexity of resource management and workflow
synchronization.
The outcome of the construction phase is a product ready to put in the hands of its end-users. At
minimum, it consists of:
The software product integrated on the adequate platforms.
The user manuals.
A description of the current release.
13
Milestone: Initial Operational Capability
At the end of the construction phase is the third major project milestone (Initial
Operational Capability Milestone).
At this point, you decide if the software, the sites, and the users are ready to go
operational, without exposing the project to high risks.
This release is often called a “beta” release.
The evaluation criteria for the construction phase involve answering these questions:
Is this product release stable and mature enough to be deployed in the user community?
Are all stakeholders ready for the transition into the user community?
Are the actual resource expenditures versus planned expenditures still acceptable?
Transition may have to be postponed by one release if the project fails to reach this milestone.
Transition Phase
The purpose of the transition phase is to transition the software product to the user
community.
Once the product has been given to the end user, issues usually arise that require you to
develop new releases, correct some problems, or finish the features that were postponed.
The transition phase is entered when a baseline is mature enough to be deployed in the
end-user domain.
This typically requires that some usable subset of the system has been completed to an
acceptable level of quality and that user documentation is available so that the transition
to the user will provide positive results for all parties.
This includes:
“beta testing” to validate the new system against user expectations
parallel operation with a legacy system that it is replacing
conversion of operational databases
training of users and maintainers
roll-out the product to the marketing, distribution, and sales teams
The transition phase focuses on the activities required to place the software into the hands of the
users. Typically, this phase includes several iterations, including beta releases, general
availability releases, as well as bug-fix and enhancement releases. Considerable effort is
expended in developing user-oriented documentation, training users, supporting users in their
initial product use, and reacting to user feedback. At this point in the lifecycle, however, user
feedback should be confined primarily to product tuning, configuring, installation, and usability
issues. The primary objectives of the transition phase include:
Achieving user self-supportability
14
Achieving stakeholder concurrence that deployment baselines are complete and
consistent with the evaluation criteria of the vision
Achieving final product baseline as rapidly and cost effectively as practical
This phase can range from being very simple to extremely complex, depending on the type of
product. For example, a new release of an existing desktop product may be very simple, whereas
replacing a nation's air-traffic control system would be very complex.
At the end of the transition phase is the fourth important project milestone, the Product Release
Milestone. At this point, you decide if the objectives were met, and if you should start another
development cycle. In some cases, this milestone may coincide with the end of the inception
phase for the next cycle. The primary evaluation criteria for the transition phase involve the
answers to these questions:
Is the user satisfied?
Are the actual resources expenditures versus planned expenditures still acceptable?
Iterations
Each phase in the Rational Unified Process can be further broken down into iterations.
An iteration is a complete development loop resulting in a release (internal or external) of
an executable product, a subset of the final product under development, which grows
incrementally from iteration to iteration to become the final system.
A process describes who is doing what, how, and when. The Rational Unified Process is
represented using four primary modeling elements:
Workers, the ‘who’
Activities, the ‘how’
Artifacts, the ‘what’
Workflows, the ‘when’
15
Activities, Artifacts, and Workers
Worker
A worker defines the behavior and responsibilities of an individual, or a group of
individuals working together as a team.
The responsibilities we assign to a worker includes both to perform a certain set of
activities as well as being owner of a set of artifacts.
16
Activity
An activity of a specific worker is a unit of work that an individual in that role may be asked to
perform. The activity has a clear purpose, usually expressed in terms of creating or updating
some artifacts, such as a model, a class, a plan. Every activity is assigned to a specific worker.
The granularity of an activity is generally a few hours to a few days, it usually involves one
worker, and affects one or only a small number of artifacts. An activity should be usable as an
element of planning and progress; if it is too small, it will be neglected, and if it is too large,
progress would have to be expressed in terms of an activity’s parts.
Example of activities:
Plan an iteration, for the Worker: Project Manager
Find use cases and actors, for the Worker: System Analyst
Review the design, for the Worker: Design Reviewer
Execute performance test, for the Worker: Performance Tester
Artifact
An artifact is a piece of information that is produced, modified, or used by a process. Artifacts
are the tangible products of the project, the things the project produces or uses while working
towards the final product. Artifacts are used as input by workers to perform an activity, and are
the result or output of such activities. In object-oriented design terms, activities are operations on
an active object (the worker), artifacts are the parameters of these activities.
Artifacts may take various shapes or forms:
A model, such as the Use-Case Model or the Design Model
A model element, i.e. an element within a model, such as a class, a use case or a
subsystem
A document, such as Business Case or Software Architecture Document
Source code
Executables
Workflows
A workflow is a sequence of activities that produces a result of observable value. In UML terms,
a workflow can be expressed as a sequence diagram, a collaboration diagram, or an activity
diagram.
17
Example of workflow
Core workflows
There are nine core process workflows in the Rational Unified Process, which represent a
partitioning of all workers and activities into logical groupings.
18
The nine core process workflows
The core process workflows are divided into six core “engineering” workflows:
1. Business modeling workflow
2. Requirements workflow
3. Analysis & Design workflow
4. Implementation workflow
5. Test workflow
6. Deployment workflow
And three core “supporting” workflows:
1. Project Management workflow
2. Configuration and Change Management workflow
3. Environment workflow
19
Although the names of the six core engineering workflows may evoke the sequential phases in a
traditional waterfall process, we should keep in mind that the phases of an iterative process are
different and that these workflows are revisited again and again throughout the lifecycle. The
actual complete workflow of a project interleaves these nine core workflows, and repeats them
with various emphasis and intensity at each iteration.
Business Modeling
One of the major problems with most business engineering efforts is that the software
engineering and the business engineering community do not communicate properly with each
other. This leads to the output from business engineering not being used properly as input to the
software development effort, and vice-versa. The Rational Unified Process addresses this by
providing a common language and process for both communities, as well as showing how to
create and maintain direct traceability between business and software models. In Business
Modeling we document business processes using business use cases. This assures a common
understanding among all stakeholders of what business process needs to be supported in the
organization. The business use cases are analyzed to understand how the business should support
the business processes. This is documented in a business object-model.
Requirements
The goal of the Requirements workflow is to describe what the system should do and allows the
developers and the customer to agree on that description. To achieve this, we elicit, organize, and
document required functionality and constraints; track and document tradeoffs and decisions.
A Vision document is created, and stakeholder needs are elicited. Actors are identified,
representing the users, and any other system that may interact with the system being developed.
Use cases are identified, representing the behavior of the system. Because use cases are
developed according to the actor's needs, the system is more likely to be relevant to the users.
The following figure shows an example of a use-case model for a recycling-machine system.
20
An example of use-case model with actors and use cases
Each use case is described in detail. The use-case description shows how the system interacts
step by step with the actors and what the system does. Non-functional requirements are described
in Supplementary Specifications. The use cases function as a unifying thread throughout the
system's development cycle. The same use-case model is used during requirements capture,
analysis and design, and test.
Analysis and Design results in a design model and optionally an analysis model. The design
model serves as an abstraction of the source code; that is, the design model acts as a 'blueprint' of
how the source code is structured and written. The design model consists of design classes
structured into design packages and design subsystems with well defined interfaces, representing
what will become components in the implementation. It also contains descriptions of how objects
of these design classes collaborate to perform use cases. The figure below shows part of a sample
design model for the recycling-machine system in the use-case model shown in the previous
figure.
21
Part of a design model with communicating design classes, and package group design
classes.
The design activities are centered around the notion of architecture. The production and
validation of this architecture is the main focus of early design iterations. Architecture is
represented by a number of architectural views. These views capture the major structural design
decisions. In essence, architectural views are abstractions or simplifications of the entire design,
in which important characteristics are made more visible by leaving details aside. The
architecture is an important vehicle not only for developing a good design model, but also for
increasing the quality of any model built during system development.
Implementation
The purpose of implementation is:
To define the organization of the code, in terms of implementation subsystems organized
in layers.
To implement classes and objects in terms of components (source files, binaries,
executables, and others).
To test the developed components as units.
To integrate the results produced by individual implementers (or teams), into an
executable system.
The system is realized through implementation of components. The Rational Unified Process
describes how you reuse existing components, or implement new components with well defined
responsibility, making the system easier to maintain, and increasing the possibilities to reuse.
Components are structured into Implementation Subsystems. Subsystems take the form of
directories, with additional structural or management information. For example, a subsystem can
be created as a directory or a folder in a file system, or a subsystem in C++ or Ada, or packages
using Java.
Test
The purposes of testing are:
To verify the interaction between objects.
To verify the proper integration of all components of the software.
To verify that all requirements have been correctly implemented.
To identify and ensure defects are addressed prior to the deployment of the software.
The Rational Unified Process proposes an iterative approach, which means that you test
throughout the project. This allows you to find defects as early as possible, which radically
reduces the cost of fixing the defect. Tests are carried out along three quality dimensions
reliability, functionality, application performance and system performance. For each of these
22
quality dimensions, the process describes how you go through the test lifecycle of planning,
design, implementation, execution and evaluation.
Deployment
The purpose of the deployment workflow is to successfully produce product releases, and deliver
the software to its end users. It covers a wide range of activities including:
Producing external releases of the software.
Packaging the software.
Distributing the software.
Installing the software.
Providing help and assistance to users.
In many cases, this also includes activities such as:
Planning and conduct of beta tests.
Migration of existing software or data.
Formal acceptance.
Although deployment activities are mostly centered around the transition phase, many of the
activities need to be included in earlier phases to prepare for deployment at the end of the
construction phase. The Deployment and Environment workflows of the Rational Unified
Process contain less detail than other workflows.
Project Management
Software Project Management is the art of balancing competing objectives, managing risk, and
overcoming constraints to deliver, successfully, a product which meets the needs of both
customers (the payers of bills) and the users. This workflow focuses mainly on the specific
aspect of an iterative development process. The goal of this workflow is to make the task easier
by providing:
A framework for managing software-intensive projects.
Practical guidelines for planning, staffing, executing, and monitoring projects.
A framework for managing risk.
In this workflow, the description of how to control the numerous artifacts produced by the many
people who work on a common project is provided. Control helps avoid costly confusion, and
ensures that resultant artifacts are not in conflict due to some of the following kinds of problems:
23
Simultaneous Update: When two or more workers work separately on the same artifact,
the last one to make changes destroys the work of the former.
Limited Notification: When a problem is fixed in artifacts shared by several developers,
and some of them are not notified of the change.
Multiple Versions: Most large programs are developed in evolutionary releases. One
release could be in customer use, while another is in test, and the third is still in
development. If problems are found in any one of the versions, fixes need to be
propagated between them. Confusion can arise leading to costly fixes and re-work unless
changes are carefully controlled and monitored.
This workflow provides guidelines for managing multiple variants of evolving software systems,
tracking which versions are used in given software builds, performing builds of individual
programs or entire releases according to user-defined version specifications, and enforcing site-
specific development policies. You describe how you can manage parallel development,
development done at multiple sites, and how to automate the build process. This is especially
important in an iterative process where you may want to be able to do builds as often as daily,
something that would become impossible without powerful automation. You also describe how
you can keep an audit trail on why, when and by whom any artifact was changed. This workflow
also covers change request management, i.e. how to report defects, manage them through their
lifecycle, and how to use defect data to track progress and trends.
Environment
The purpose of the environment workflow is to provide the software development organization
with the software development environment—both processes and tools—that are needed to
support the development team. This workflow focuses on the activities to configure the process
in the context of a project. It also focuses on activities to develop the guidelines needed to
support a project. A step-by-step procedure is provided describing how you implement a process
in an organization. The environment workflow also contains a Development Kit providing you
with the guidelines, templates and tools necessary to customize the process.
Basic Definition
A methodology is explained as the science of methods.
A method is a set of procedures in which a specific goal is approached step by step.
Many methodologies are available to choose from for system development.
24
The methodologies developed by Rumbaugh et al., Booch, and Jacobson are the origins
of the Unified Modeling Language (UML) and the bases of the UA
Rumbaugh Methodologies OMT (Object Modeling Technique) describes a method for the
analysis, design, and implementation of a system using an object-oriented technique. Class
attributes, method, inheritance, and association also can be expressed easily.
Phases of OMT
Analysis
System Design
Object Design
Implementation
Booch Methodology
The Booch methodology covers the analysis and design phases of systems development.
The Booch method consists of the following diagrams:
1. Class diagrams
2. Object diagrams
3. State transition diagrams
4. Module diagrams
25
5. Process diagrams
6. Interaction diagrams
Conceptualization:
• Establish the core requirements of the system
• Establish a set of goals and develop prototype to prove the concept
Evolution or implementation
• Successively refine the system through many iterations.
• Produce a stream of software implementations, each of which is refinement of the prior one
26
Maintenance
• Make localized changes to the system to add new requirements and eliminate bugs
Jacobson Methodologies The Jacobson et al. methodologies (e.g., OOBE, OOSE, and
Objectory) cover the entire life cycle and stress traceability between the different phases.
Patterns
• A pattern is an instructive information that captures the essential structure and insight of a
successful family of proven solutions to a recurring problem that arises within a certain context
and system of forces.
27
• The main idea behind using patterns is to provide documentation to help categorize and
communicate about solutions to recurring problems.
• The pattern has a name to facilitate discussion and the information it represents.
• A good pattern will do the following:
1. It solves a problem. Patterns capture solutions, not just abstract principles or strategies.
2. It is a proven concept. Patterns capture solutions with a track record, not theories or
speculation.
3. The solution is not obvious. The best patterns generate a solution to a problem
indirectly—a necessary approach for the most difficult problems of design.
4. It describes a relationship. Patterns do not just describe modules, but describe deeper
system structures and mechanisms.
5. The pattern has a significant human component.
6. All software serves human comfort or quality of life; the best patterns explicitly appeal to
aesthetics and utility.
Frameworks
• A framework is a way of presenting a generic solution to a problem that can be applied to all
levels in a development.
• A single framework typically encompasses several design patterns and can be viewed as the
implementation of a system of design patterns.
• The main motivation of UA is to combine the best practices, processes, methodologies, and
guidelines along with UML notations and diagrams.
• The unified approach to software development revolves around (but is not limited to) the
following processes and components:
28
• Incremental development and prototyping.
• Continuous testing.
UA Object-Oriented Design
• Booch provides the most comprehensive object-oriented design method.
• However, Booch methods can be somewhat imposing to learn and especially tricky to figure
out where to start.
• UA realizes this by combining Jacobson et al.'s analysis with Booch's design concept to create
a comprehensive design process.
29
Unified Modeling Language (UML)
Why Modeling?
o Models make it easier to express complex ideas.
o For example, an architect builds a model to communicate ideas more easily to clients.
Advantages of Modeling
Models reduce complexity by separating those aspects that are unimportant from those
that are important.
Models enhance learning.
The cost of the modeling analysis is much lower than the cost of similar experimentation
conducted with a real system.
Manipulation of the model (changing variables) is much easier than manipulating a real
system.
30
Avoid excess model revisions, as they can distort the essence of your model. Let
simplicity and elegance guide you through the process.
UML is
• A way to describe your software
• more precise than English
• less detailed than code
31
SYMBOLS COMMONLY USED IN UML AND THEIR MEANIGS
Symbol Meaning
Use case: Defines what the user should achieve from the system
Class name Class diagram: Represents classes forming the system
Attributes
Methods
Class:Object
Object diagram: Represents the objects of the system
Attributes
State name
State symbol: Represents the state of an object after an event has occurred
State variables
Association: Represent the relationship between any two interacting objects
Activities
Generalization: Represents inherence relationship
Aggregation: Represents part-whole relationship where part component can exist on its own
Composition: Represents part-whole relationship where part component cannot exist on its own
Dependency: Defines a relationship where a base use case depends on another use case to operate.
<< >> Stereotype: Label attachments that add extra classification to model items
Actor: Anything that interacts with the system to achieve given objectives
32
UML Diagrams
4. Implementation diagram:
Activity
State
Diagrams
Diagrams
Model
Sequence
Component
Diagrams
Diagrams
Collaboration Deployment
Diagrams Diagram
33
Use Case Diagram
A use case represents the functionality that a user should achieve from the system being
developed.
Use case diagrams are created to visualize the relationships between actors and use cases
An actor is someone or something that must interact with the system under development
A use case is a pattern of behavior the system exhibits
Use cases are written from an actor point of view
The diagram below shows a use case diagram for an ATM cash system.
The diagram has one actor represented by Client and three use cases namely: Withdraw
money, Transfer money and check money.
Transfer Money
Client
For a given use case to be realized by an actor, some steps must be followed. These
steps are called use case scenarios.
If we take Withdraw money use case from the above diagram, the use case scenarios will be:
34
The customer has enough money, so the machine returns the customer’s card.
The money is dispensed through the slot in the front of the machine.
Connect externally
System administrator
Store files
Project manager
Access company documents
Share printers
Marketing manager
Connect to internet
Online shopping
Sales representative
The customer browses the online catalogue and selects the items that he/she would like
to purchase
These items are added to the shopping basket.
When the customer has finished browsing and wishes to pay, the customer then enters
the credit card details and decides how goods should be delivered.
The system checks the authorization on the credit card and confirms the sale both
immediate and by email.
35
Relationships
Inclusion;
Generalisation;
Extension;
Grouping.
If you find that some behaviours are being repeated in two or more sections, the
UML provides a solution to avoid repetition. Inclusion allows developers to
create use cases that can simply be referred to each time they are needed,
rather than laborious rewriting or a lot of cut and pasting. Apart from the time
saved, another advantage of this approach is that the developer can make
changes to one particular use case. If the behaviour had been repeatedly
rewritten, the amendments would also need to be rewritten by hand for each
occurrence. Inclusion use cases are dependent on the use case that contains
them. They therefore cannot be used on their own, and must be used in
conjunction with the use case that includes them.
Example
You may find that if you were designing a drinks machine, you would need to
follow a distinct sequence of events every time you needed to restock or service
the machine. The following steps could be used to create an open machine use
case, which would form the basis of other use cases, such as a refill machine
.
36
<<Include>>
Restock the
drinking machine Open machine
<<extend>> <<Include>>
Close machine
Restock according
to best seller
Notation for stereotype: Stereotype is a label attachment that adds extra classification to
model items. The symbolic representation of a stereotype is << >>. E.g. <<include>>,
<<extend>>, <<interface>>.
Use cases can inherit behavior and meaning from parents in the same way that
classes can. This type of modification is known as generalization.
Example1
For instance, you may already have a use case for buying a drink that you could add
behaviors to. The buy a drink use case could then be used as the parent for buy a glass
of drink. The generalization could then add steps for adding mixers, ice and lemon in a
child use case.
37
Example2
If there are three use cases: order shoes, order books and order goods. These use
cases can be represented by a generalization relationship as follows:
Order goods
Generalization relationship
You may find that you need to make additions to your standardized or base use
case. The base use case can therefore be extended to form the basis of new
use cases. The person who maintains the machine may find that there are
certain types of drink that are most commonly bought. The supplier may decide
to increase the number of cans of these brands, and no longer stock the less
popular brands. The use case for restocking the machine could be extended to
allow for restocking according to demand. Extension use cases only occur at
specified points within the base use case’s sequence. The points where
extensions occur are called extension points.
38
Example of Extension Use Case
Someone wishing to buy items from an online shop must log on to the system,
and provide their account details. These will link the billing and delivery details
for the customer with the items in the shopping basket. New customers however,
will not have an existing account with the company, and will need to create one
before they can complete their order. The extension point occurs at log on to
account.
Enter name.
Enter address and telephone number.
Enter email address.
Enter password.
Confirm password
Enter payment details
<<Extend>>
The developer may find it helpful to organize use cases, if there are several in
existence. It may be that the system is comprised of several subsystems, or the
client is being interviewed about the system requirements. Each system
requirement would be a discrete use case, and it may prove useful to be able to
organize and categorize these requirements.
39
Grouping Notation
The notation for grouping use cases is to simply include them inside a package,
as shown in Figure below
Customer
Browse Catalogue
Log onto system
Buy goods
These two types of use case are concerned with two different aspects of system
design. Business use cases are concerned with how a business responds to a
particular customer or event, whereas system use cases are concerned with the
interaction between the system or software and the user.
A business use case can be useful when considering how to meet an actor’s
goal, for example, how best to allow the customer to buy the goods they desire.
Sometimes it is more productive to change the business practice to a solution to
a problem, rather than try to change the system to accommodate the problem.
A system use case is more useful for planning the system, and is concerned with how
the system behaves in particular scenarios. For each business use case that has been
identified, there should follow a set of system use cases.
40
Class Diagrams
A class diagram describes the types of objects in the system and the various kinds of
static relationships that exist among them.
A class diagram is a graphical representation of a static view on declarative static
elements.
A class diagram shows the existence of classes and their relationships in the logical view
of a system
Class
Attributes
Operations
Relationships
Associations
Generalization
Dependency
Realization
A class is the description of a set of objects having similar attributes, operations, relationships
and behavior.
41
Attributes
Classes have attributes that describe the characteristics of their objects.
Attributes are atomic entities with no responsibilities.
Attribute syntax (partial):
o [visibility] name [ : type ] [ = defaultValue ]
Class scope attributes are underlined
Visibility
• Visibility describes whether an attribute or operation is visible and can be referenced from
classes other than the one in which they are defined.
• Language dependent
o Means different things in different languages
• UML provides four visibility abbreviations: + (public) – (private) # (protected) ~ (package)
Associations
• A semantic relationship between two or more classes that specifies connections among their
instances.
• A structural relationship, specifying that objects of one class are connected to objects of a
second (possibly the same) class.
• Example: “An Employee works for a Company”
• An association between two classes indicates that objects at one end of an association
“recognize” objects at the other end and may send messages to them.
• This property will help us discover less trivial associations using interaction diagrams
42
Role name
Association name
Instructor Instructs
StaffMembers Student
1..* *
Role
Multiplicity
Navigable (Uni-
directional)
association *
Prerequisites
Courses
0..3
Reflexive
Association
Aggregation
2..* 1..*
Car Door House
Whole Part
Composition
It is a relationship in which the components of the class they constitute are in a part-
whole association.
It is represented as a hierarchy with the whole class at the top and the components
below.
Each part component must belong to the whole
Each part component cannot exist on its own
43
Coin
Tail Head
Generalization
Shape
(Abstract)
Draw(){abstract}
Circle Rectangle
draw() draw()
Dependency
A dependency is a relation between two classes in which a change in one may force changes in
the other although there is no explicit association between them. A stereotype may be used to
denote the type of the dependency.
44
<<Friends>>
Iterator Vector
Realization
A realization relationship indicates that one class implements a behavior specified by another
class (an interface or protocol). An interface can be realized by many classes. A class may realize
many interfaces.
Object Diagrams
Student Student:Student1
Course Course=”BBIT”
AverageMarks AverageMarks=78
SetDetails( )
Grade Grade=’A’
getDetails( )
printDetails( )
45
Differences between class diagram and an object diagram
Interactive Diagrams
Interaction diagrams describe how groups of objects collaborate to get the job done. Interaction
diagrams capture the behavior of a single use case, showing the pattern of interaction among
objects. The purpose of Interaction diagrams is to:
Model interactions between objects
Assist in understanding how a system (a use case) actually works
Verify that a use case description can be supported by the existing classes
Identify responsibilities/operations and assign them to classes
Sequence Diagrams
46
Sequence diagram show how objects in the system will interact with each other. An object is an
instance of a class, that is, it is an occurrence of a class. For example a teacher is an instance of a
human being class. Taking a microwave oven as example: A microwave has a number of
components including: A timer, heating element and a turn table. The use case for cooking food
in the microwave involves the following steps:
The timer is set for a number of minutes
The turntable rotates
The heating element is activated to cook the food
The timer reaches the end of its set time
The turntable stops rotating
The heating element is turned off
Set time
Keep
Time
Keep
rotating
15 minutes rotating
Sequence diagrams come in two forms to deal with real life scenarios: the first deals
with an action in which one scenario, and only one scenario, is possible. This is known
as an instance sequence diagram. The second deals with actions, following which a
number of scenarios can occur. This is known as a generic sequence diagram. It is
probably useful to remember that for every use case, a sequence diagram is used to
47
illustrate the activities, sequence and relationships therein.
A real life example serves to illustrate the difference. When a bank customer
attempts to draw money from a cashpoint terminal, there are two possible
scenarios. The first is that in which everything happens as it should. His/her card
is inserted, the PIN number is checked, the card is checked for validity, the bank
balance is checked to see if sufficient funds are available to cover the withdrawal
amount, the cash dispenser checks to see it has sufficient funds of the selected
denomination and the cash is then dispensed.
In an ideal world, all of the above would be correct and could be considered a
unique instance, and an instance sequence can occur.
a. The customer inserts his/her cashpoint card into the card slot.
b. The PIN number is entered and the amount of money required selected.
c. The account is checked for available funds.
d. The dispenser is checked for available funds of the correct denomination.
e. Assuming everything is correct, the card is ejected.
f. The correct amount of cash is dispensed through the cash slot.
An instance sequence diagram modelling this ideal scenario is shown in Figure below.
48
:CashPoint Panel :Register :Dispenser
Insert(Input)
Send(Amount)
Deliver(Amount)
If the situation turns out to be less than ideal and a number of eventualities could
prevent the cash being issued to order. For example:
These situations are catered for and are modelled as a generic sequence
diagram, as shown in Figure below.
49
:CashPoint Panel :Register :Dispenser
[CashStore>Amount] Disense(Amount)
Collaboration Diagrams
Collectively, the objects which interact to perform some task, together with the links between
them, are known as a collaboration
Objects: Each object is shown as a circle or a rectangle, which is labeled as objectName:
className
Links: Links between objects are shown like associations in the class model.
Actors: Actors can be shown as on a use case diagram
A collaboration diagram represents a set of objects related in a particular context, and the
exchange of their messages to achieve a desired outcome.
Used for design of: components, object, subsystems
Diagrams show entity event responses
Event is equivalent to receiving a message
50
:Name1
1:Add( )
3:Update( )
:Name3 :Name2
2:Modify( )
The collaboration diagram can deal with conditions in the same way that the
sequence diagrams do. Remember, the process still has to be addressed
sequentially and to address this, the messages are numbered sequentially.
Examining the example of the ‘best case’ scenario for the cashpoint machine,
i.e. the customer puts in his/her card and withdraws the cash amount required,
the collaboration diagram would look as in Figure below.
51
Insert(Input, amount)
:Cashpoint Panel
1:add(input, amount)
3:deliver(amount)
:Dispenser :Register
2:deliver(amount)
Collaboration diagram for best case scenario cash withdrawal
Conditions are represented in the same way as in the sequence diagram by putting
them inside square brackets and following this with the message label. The example of
the cashpoint machine illustrates the use of sequence numbering and also the use of
conditions. In this example, the following conditions have to be considered:
The PIN number is incorrect.
The customer’s bank account does not contain adequate funds.
The bank’s funds do not cover the amount of cash requested.
If the PIN number is wrong, the step in which a message is displayed on the
front panel needs to be added, along with the conditions. If the funds in the
customer’s account do not cover the withdrawal amount, a step to send a
different message to the front panel is included (again with the necessary
conditions). Finally, if the cash held in the cashpoint (the cashstore) does not
cover the cash required, a further step needs to be added to send another
message to the front panel. The collaboration diagram to model this example
with the conditions stated, is shown in Figure below.
52
Insert(Input,amount)
:Cashpoint Panel
1:add(input,amount)
:Dispenser :Register
Note: After any condition statement, the number before the decimal point
sequentially states the sequence and the number after the decimal point states
the alternative branches that can be taken when the condition statement is
checked. This is called nesting.
Active object
It may be necessary for a specific object to control the flow and interacts with
other passive objects to maintain the workflow. This object is referred to as an
active object and is shown in the collaboration diagram as a rectangle, but to
differentiate it from the passive objects, the rectangle’s border is made bold. As
an example, an office typing pool has an administrator whose job it is to receive
incoming work and allocate it to the typists. The collaboration diagram is shown
in Figure below with the administrator shown as an active object.
53
3:do(Letter)
:Administrator :Typist
1:TypingRquest(Letter) 4:lookup(Report)
5:return(Report)
2:getRquest(Report)
5:return(Report)
:Manager :Typist
Synchronization
Synchronization arises when an object can only send a message when, and only when,
several other messages have been sent. In effect, it has to synchronize its message
along with a set of other messages. As a practical example to demonstrate this, a house
building company has the following process in place for building a new housing estate:
a) The architect who has designed the estate, asks the quantity surveyor to
calculate the materials and labour to be used.
b) The quantity surveyor asks the construction manager to produce a bill of
materials to collate all the materials required.
c) The construction manager asks the buyer to obtain quotations for the
materials from a local supplier.
d) The buyer asks the local supplier for a quotation.
e) After the construction manager has produced a bill of materials, the
accounts department requires a copy to budget for the development.
The key point here is that step e) cannot be undertaken until steps b) and have been
completed. In other words, the system needs to synchronize. The collaboration diagram
syntax is to show step e) as a separate process. This time, instead of preceding the
message with a number, it is preceded with a list of the messages that have to be
completed before step e) can take place. A comma separates one list item from another
and the list ends with a slash (/). The diagram in Figure below illustrates this scenario.
54
1:calculate(materials,estate)
:Architect
:QuantitySurveyor
2:assign(materials,estate)
:ContsructionManager
:Accountant 3:requestQuotation(materials,estate)
:Buyer
2,3/calculateBudget(materials,estate)
:Budget
*[Suppliers] 4:getQuotation(materials,estate)
:Supplier
Packages
A package is a general purpose grouping mechanism. A package can be used to group any UML
element (e.g. use case, actors, classes, components and other packages. Commonly used for
specifying the logical distribution of classes. A package does not necessarily translate into a
physical sub-system.
Name
55
Packages and Class Diagrams
• Emphasize the logical structure of the system (High level view)
c a
Emphasize the interface between packages by showing relations and dependencies between
public classes. Add package information to class diagrams
State Diagram
A statechart diagram (also called a state diagram) shows the sequence of states that an object
goes through during its life in response to outside stimuli and messages. A statechart diagram is a
view of a state machine that models the changing behavior of a state. Statechart diagrams show
the various states that an object goes through, as well as the events that cause a transition from
one state to another.
A state represents a condition during the life of an object during which it satisfies some
condition or waits for some event. Start and end states represent the beginning or ending of a
process. A state transition is a relationship between two states that indicates when an object
can move the focus of control on to another state once certain conditions are met.
56
Actions in a Statechart diagram
Each state on a state chart diagram can contain multiple internal actions.
An action is best described as a task that takes place within a state.
There are four possible actions within a state:
On entry
On exit
Do
On event
State variables
Activities
End point of a
Starting point
Activities sequence
of a sequence
Activity Diagram
• Activity Diagram is a special kind of Statechart diagram, but showing the flow from activity to
activity (not from state to state).
• Activity is an ongoing non-atomic execution within a state machine. Activities ultimately result
in some action.
– A real world process or execution of a software routine
• Action is made up of executable atomic computations that result in a change in state of the
system or the return of a value (i.e., calling another operation, sending a signal, creating or
destroying an object, or some pure computation).
57
Action states - executable, atomic computations (states of the system, each representing the
execution of an action) – cannot be decomposed.
Activity states – non-atomic; can be further decomposed; can be represented by other activity
diagrams – a composite whose flow of control is made up of other activity states and action
states
Select site
Commission architect
Develop plan
Bid plan
[not accepted]
[else]
:CertificateOfOccupancy
Finish construction
[completed]
An
The series is calculated by the sum of the previous two numbers in a number series to
arrive at the next number. The first two calculations automatically become 1, as there
are not two numbers before them. The next number is 2, so the calculation can be
58
performed, i.e. 1+2=3, and the next becomes 3+2=5 and then 5+3=8. The resulting
series is: 1,1,2,3,5,8,13,21…and so on. The operation activity diagram is shown in
Figure 5.61.
Format:
calculateNumber(n)
“The” Counter “th
Number is:” Answer
Answer1:=1
Counter:=1
[n=1] Print(Answer,counter)
Answer:=Answer1
[n>1]
Answer2:=1
Counter:=2
[n=2]
Answer:=Answer2
[n>2]
Answer:=Answer1+Answer2
Counter:=Counter+1
mm
[n>counter]
Answer1:=Answer2
Answer2:=Answer
59
Component Diagram
Component diagrams, along with deployment diagrams are solely concerned with the
development of computer systems. Modern development processes use components, which is
an important aspect in projects that rely on a team for development. A component can be a
table, data file, executable program and many other things. If a Student class represents an
abstract form of a set of attributes and behaviors, then Undergraduate class or Postgraduate
class represents component diagram implementation of a software of Student class e.g
Undergraduate.exe (a software executable of Undergraduate class).
Undergraduate.exe
Deployment Diagram
Deployment diagram shows the configuration of run-time processing elements and the
software processes living on them. The deployment diagram visualizes the distribution of
components across the enterprise
60
Object oriented analysis involves:
Analysis
Analysis is the process of transforming a problem definition from a fuzzy set of facts and myths
into a coherent statement of a system‘s requirements. The main objective of the analysis is to
capture:
a complete, unambiguous, and consistent picture of the requirements of the system and
what the system must do to satisfy the users' requirements and needs.
Requirements Difficulties
Three most common sources of requirements difficulties are:
1. Incomplete requirements.
2. Fuzzy descriptions (such as fast response).
3. Unneeded features.
61
Determine the sequence.
Develop collaboration diagrams
O-O Analysis
Develop an activity diagram of the business processes that can provide an overall view of the
system.
62
Use Case Model
Use cases are scenarios for understanding system requirements. The use-case model describes
the uses of the system and shows the courses of events that can be performed. Use case
defines what happens in the system when a use case is performed. The use-case model tries to
systematically identify uses of the system and therefore the system's responsibilities.
"A Use Case is a sequence of transactions in a system whose task is to yield results of
measurable value to an individual actor of the system."
Use Associations
The use association occurs when you are describing your use cases and notice that some of them
have common subflows. The use association allows you to extract the common subflow and
make it a use case of its own.
Extends Associations
The extends association is used when you have one use case that is similar to another use case
but does a bit more or Is more specialized; in essence, it is like a subclass.
63
Library
Checking library
Extends card
Uses
Inter library loan
Return books
Calculation
Performing search clerk
Member
Reading books and
news paper
Supplier
Purchasing supplies
64
Guidelines for Finding Use Cases
For each actor, find the tasks and functions that the actor should be able to perform or
that the system needs the actor to perform.
Name the use cases.
Describe the use cases briefly by applying terms with which the user is familiar.
Documentation
An effective document can serve as a communication vehicle among the project's team members,
or it can serve as initial understanding of the requirements.
Familiar Vocabulary
Use a vocabulary that your readers understand and are comfortable with.
The main objective here is to communicate with readers and not impress them with buzz
words.
The main objective of the analysis is to capture a complete, unambiguous, and consistent picture
of the requirements of the system. You should Construct several models and views of the system
to describe what the system does rather than how it does them. Capturing use cases is one of the
first things to do in coming up with requirements. Every use case is a potential requirement. The
key in developing effective documentation is to eliminate all repetition; present summaries,
reviews, organization chapters in less than three pages. Use the 80–20 rule: 80 percent of the
work can be done with 20 percent of the documentation.
65
Object Analysis: Classification
Classification involves:
Intelligent classification is intellectually hard work and may seem rather arbitrary. Martin and
Odell have observed in object-oriented analysis and design, that “In fact, an object can be
categorized in more than one way.”
• By the convention, the class name must begin with an upper case letter.
• For compound words, capitalize the first letter of each word - for example, Loan Window.
66
Guidelines for Identifying Super-sub Relationships: Top-down
Look for noun phrases composed of various adjectives on class name.
Example, Military Aircraft and Civilian Aircraft.
Only specialize when the sub classes have significant behavior.
Bottom-up
Look for classes with similar attributes or methods.
Group them by moving the common attributes and methods to super class.
Do not force classes to fit a preconceived generalization structure.
Reusability
Move attributes and methods as high as possible in the hierarchy.
At the same time do not create very specialized classes at the top of hierarchy.
This balancing act can be achieved through several iterations.
Multiple inheritance
Avoid excessive use of multiple inheritances.
It is also more difficult to understand programs written in multiple inheritance system.
Identifying Class Responsibility by Analyzing Use Cases and Other UML Diagrams
Attributes can be identified by analyzing the use cases, sequence/collaboration, activity,
and state diagrams.
67
OBJECT ORIENTED DESIGN
To explain how a software design may be represented as a set of interacting objects that
manage their own state and operations
Characteristics of OOD
Design axioms
Main focus of the analysis phase of software development ”what needs to be done”
Class‘s attributes, methods, and associations identified during analysis must be designed
for implementation as a data type expressed in the implementation language
During the design phase, we elevate the model into logical entities, some of which might
relate more to the computer domain (such as user interface, or the access layer) than the
real world or the physical domain (such as people or employees). Start thinking how to
actually implement the problem in a program.
The goal to design the classes that we need to implement the system.
68
Design is about producing a solution that meets the requirements that have been specified
during analysis.
Analysis Design
Focus on understanding
the problem Focus on understanding the solution
Idealized design Operations and attributes
Behavior performance
System structure close to real code
Functional requirements object lifecycles
A small model non-functional requirements
a large model
OO Design Axioms
An axiom = is a fundamental truth that always is observed to be valid and for which there
is no counterexample or exception.
69
Design Patterns
Provides a scheme for refining the subsystems or components of a sw system or the
relationships among them
Are devices that allow systems to share knowledge about their design, by describing
commonly recurring structures of communicating components that solve a general design
problem within a particular context
The main idea to provide documentation to help categorize & communicate about
solutions to recurring problems
The pattern has a name to facilitate discussion and the information it represents
Designing classes
Objectives - To explain how a software design may be represented as a set of interacting objects
that manage their own state and operations To describe the activities in the object-oriented
design process To introduce various models that describe an object-oriented design To show how
the UML may be used to represent these models
Characteristics of OOD
Characteristics of OOD Objects are abstractions of real-world or system entities and
manage themselves Objects are independent and encapsulate state and representation
information.
System functionality is expressed in terms of object services Shared data areas are
eliminated.
Objects communicate by message passing Objects may be distributed and may execute
sequentially or in parallel
Advantages of OOD
Advantages of OOD Easier maintenance.
Objects may be understood as stand-alone entities Objects are appropriate reusable
components For some systems, there may be an obvious mapping from real world entities
to system objects
Object-oriented development
Object-oriented analysis, design and programming are related but distinct OOA is concerned
with developing an object model of the application domain OOD is concerned with developing
an object-oriented system model to implement requirements OOP is concerned with realizing an
OOD using an OO programming language such as Java or C++
70
Objects and object classes
Objects and object classes Objects are entities in a software system which represent instances of
real-world and system entities Object classes are templates for objects. They may be used to
create objects Object classes may inherit attributes and services from other object classes
Objects
An object is an entity which has a state and a defined set of operations which operate on that
state. The state is represented as a set of object attributes. The operations associated with the
object provide services to other objects (clients) which request these services when some
computation is required. Objects are created according to some object class definition. An object
class definition serves as a template for objects. It includes declarations of all the attributes and
services which should be associated with an object of that class.
Object communication
Conceptually, objects communicate by message passing. Messages - The name of the service
requested by the calling object. Copies of the information required to execute the service and the
name of a holder for the result of the service. In practice, messages are often implemented by
procedure calls Name = procedure name. Information = parameter list.
Message examples:
// Call a method associated with a buffer
// object that returns the next value
// in the buffer
v = circularBuffer.Get () ;
// Call the method associated with a
// thermostat object that sets the
// temperature to be maintained
thermostat.setTemp (20) ;
71
operations from its super class and may add new methods or attributes of its own Generalisation
in the UML is implemented as inheritance in OO programming languages
Advantages of inheritance
Advantages of inheritance It is an abstraction mechanism which may be used to classify entities
It is a reuse mechanism at both the design and the programming level The inheritance graph is a
source of organizational knowledge about domains and systems
UML associations
Objects and object classes participate in relationships with other objects and object classes. In the
UML, a generalized relationship is indicated by an association Associations may be annotated
with information that describes the association. Associations are general but may indicate that an
attribute of an object is an associated object or that a method relies on an associated object
Concurrent objects:
The nature of objects as self-contained entities make them suitable for concurrent
implementation. The message-passing model of object communication can be implemented
directly if objects are running on separate processors in a distributed system
72
service Active objects Objects are implemented as parallel processes and the internal object state
may be changed by the object itself and not simply by external calls.
System Implementation
System implementation is the translation of the system design into an object oriented
programming language that can be executed in a computer to generate the expected output. The
example below represents a program that comprises two classes that demonstrate inheritance.
Object instantiation, method overriding, and accessibility scope concepts are clearly illustrated,
Example:
#include <iostream.h>
#include <string.h> // must be included to handle string of characters
# define TAX_RATE 0.15 // constant declaration
class Employee
{
protected:
public:
73
void setHouseAllowance(double hAllowance)
{ houseAllowance = hAllowance ;}
int getEmployeeNo()
{ return employeeNo;}
double getSalary()
{ return salary;}
double getHouseAllowance()
{ return houseAllowance;}
double computeTax()
{
double tax = (salary + houseAllowance)*TAX_RATE;
return tax;
}
double computeGrossPay()
{
double gPay = salary + houseAllowance;
return gPay;
}
double computeNetPay()
{
double gPay = salary + houseAllowance;
double tax = gPay*TAX_RATE;
double nPay = gPay - tax;
return nPay;
}
void displayInfo()
{
cout<<"\n"<<"Name : "<<name;
cout<<"\n"<<"EmployeeNo : "<<employeeNo;
cout<<"\n"<<"Salary : "<<salary;
74
cout<<"\n"<<"HsAllowance : "<<houseAllowance;
cout<<"\n"<<"GrossPay : "<<computeGrossPay();
cout<<"\n"<<"TaxAmount : "<<computeTax();
cout<<"\n"<<"NetPay : "<<computeNetPay();
cout<<"\n";
/*
Inheritance declaration. Manager class is created from Employee class and inherits all public
and protected members of Employee class
*/
class Manager:public Employee
{
protected:
double carAllowance; // Unique to manager
double medicalAllowance; // Unique to manager
public:
double getCarAllowance()
{ return carAllowance;}
double getMedicalAllowance()
{ return medicalAllowance;}
//Function overridding
double computeTax()
75
{ double tax = (salary + houseAllowance + carAllowance +
medicalAllowance)*TAX_RATE;
return tax;
}
main()
{
//Variable declaration
76
char name[30];
int empNo;
double salary;
double houseAllowance;
double carAllowance;
double medicalAllowance;
int choice;
cout<<"\n Type 1 to choose ordinary employee OR 2 to choose Manager: Then Type Enter
Key";
cout<<"\n";
cin>>choice;
switch(choice)
{
case 1:
cout<<"\n Enter Name, EmployeeNo, Salary, House Allowance: separated by spaces :
Then Type Enter Key ";
cout<<"\n";
cin>>name>>empNo>>salary>>houseAllowance;
// method call
emp.setName(name);
emp.setEmployeeNo(empNo);
emp.setSalary(salary);
emp.setHouseAllowance(houseAllowance);
emp.displayInfo();
break;
case 2:
77
cin>>name>>empNo>>salary>>houseAllowance>>carAllowance>>medicalAllowance;
// method call
man.setName(name);
man.setEmployeeNo(empNo);
man.setSalary(salary);
man.setHouseAllowance(houseAllowance);
man.setCarAllowance(carAllowance);
man.setMedicalAllowance(medicalAllowance);
man.displayInfo();
break;
default:
cout<<"\n Invalid Entry: Type 1 to choose ordinary employee OR 2 to choose Manager ";
cout<<"\n";
break;
return 0;
System Testing
Introduction
Testing is a process of detecting errors in a software program. The detected errors must be
corrected to ensure that the software meets its specifications and user requirements. Any
testing process applied throughout software development is either static or dynamic. Static
testing process involves reading and checking documents concerning requirements, reading
and checking of code without running the software. Dynamic testing process involves running
the code to check its output. Both types of testing process have been done. Dynamic testing
can be done using two approaches – black box testing and white box testing. Black box testing
treats the system as a black box that receives inputs and produce outputs. It is based on
assessment of requirements and functionality of the system. White box testing involves the
coverage of code statements, branches, paths and conditions of execution. It tests the internal
logic of the application’s code. The documentation in this chapter covers types of dynamic
78
testing and evaluation of the test results. In order to conduct testing process, a test plan is
required. The content of a test plan includes:
Component testing
This refers to testing of each individual module in a suite of programs. Each module is tested
with correct and incorrect data to reveal loopholes in the code. It often takes place in parallel
with coding to provide intermediate results that reveal logic, functionality and error handling of
a unit. This testing is done at the source or code level for language, specifically for identifying
programming errors such as bad syntax, logic errors or to test particular functions or code
modules.
Functional/integration testing
Specific functional user requirements would be tested to ensure that the system meets these
requirements and ensure that the developer has developed the right product. Each user specific
function would be thoroughly tested to ensure that they perform their tasks properly. The test
would try to find errors within inputs and outputs of these functions. The results display and
format would be closely examined to make sure that it meets user requirements. This test would
also include tests such as:
The interfaces to ensure that they are functioning well by checking if the interface
components are properly integrated and behaving as expected – especially verifying that
the appropriate action is associated with correct interaction method of designed mouse
click events, key strokes etc.
The interaction of the system’s graphical user interface (GUI) and the backend database.
In this case, data would be inserted from the front end using data entry forms and check if
each entry corresponds to the correct database table field, also check if data inserted is in
the desired format.
The form interaction design would also be tested to ensure that the information
presentation to the user is in a manner that the users can easily find and/or perform the
operation they want. The design should be an abstract representation of the abstract
physical forms that the system employees use.
79
System testing
The system would be properly tested to verify its functionality. This would be achieved by
ensuring that relevant tests have been performed such as integration tests, unit tests, functional
tests and acceptance tests. This test would be used as the overall testing of the system after the
system has fully been developed just before it is taken to the client, where the client will perform
acceptance testing with the developer and raise any adjustments they want at different system
levels. This type of testing would be designed to ensure that the system meets all functional and
non functional user requirements. This test would also focus on the behavior of the system once
it is subjected to different inputs. It would also focus on how different components of the system
interact with each other for optimal performance of the system (integration testing). Different
user demand would be tested against the system which would include error message testing and
several screen mappings.
Acceptance testing
This is done by the system client and after all other types of testing have been performed. The
system is taken to the commissioner to test whether it adheres to the agreed upon functional
requirements in System Requirements Specification Document (SRS). The client also uses black
box testing to evaluate the system functionality. Mission critical errors in functional
requirements are corrected immediately and regression testing performed to ensure that changes
made do not affect other system components or functions. Upon successful acceptance testing,
the system will then be implemented; a process that will see the developed system is in place and
working as intended.
Performance testing
This type of testing relates to the expected level of the processing time of the transaction or response time
especially when the system is being fully utilized.
Volume testing
This testing ensures that the system can handle the expected number of users or transaction’s processing
speed.
Regression testing
This involves ensuring that the system corrections do not result in the same or other errors as corrections
are being made.
Evaluation testing
For accurate results on testing, once alpha test is finished an independent body will be assigned to carry
out a beta test. This will guarantee software quality since the body does not have idea on the system
structure. Therefore they will use different test data which may help in discovering more errors. Their
recommendations will be considered and errors corrected accordingly. Later the system will be released
to the end user. For the purpose of software maintenance and documentation, all the test records and
test logs will be recorded and documented for future reference both for alpha and beta test.
80