0% found this document useful (0 votes)
13 views

Handout1 Introduction To OOAD and Programming

This document provides an overview of object-oriented analysis, design and programming (OOADP) concepts. It discusses several key OOADP elements including analysis, design, programming, paradigms, object-oriented programming, unified modeling language (UML), and structured programming. It also includes examples of how these concepts can be modeled using UML activity diagrams.

Uploaded by

eugenemwangi08
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Handout1 Introduction To OOAD and Programming

This document provides an overview of object-oriented analysis, design and programming (OOADP) concepts. It discusses several key OOADP elements including analysis, design, programming, paradigms, object-oriented programming, unified modeling language (UML), and structured programming. It also includes examples of how these concepts can be modeled using UML activity diagrams.

Uploaded by

eugenemwangi08
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Object Oriented

Analysis, Design and


Programming

Introduction to OOADP
concepts and fundamentals
Analysis, design and programming paradigm (ADPP)
Knowledge and experience created by a community and
accepted as the basis of carrying out research and work
in a field.
Paradigm consists of:
1. problem solving strategies
2. Problem solving philosophy – dealing with how
knowledge about paradigm is acquired and community
values.
3. Processes
4. Constructs
5. Methods
These elements are used to capture transform
knowledge of problem into a high level solution that is
transformed into a programming language. Dividing these into
three or more stages is divide and conquer principle because smaller parts problem are
usually easier to solve than whole problem
Several ADPPS
This so no single best paradigm for developing all
types of software systems so several paradigms
have been created and new ones are being created.
1. New knowledge is being created making it
possible to create new paradigms and innovations
2. Improvement in computer technology such as
increased memory and speed result in demand for
more powerful and different types software that
create need for new paradigms. For example
need to process very large amounts of data , data
that is produced at very high speed has resulted
in Big Data paradigm.
3. Research on how to solve software development
problems discovers solutions and new SD
paradigms
Object oriented paradigm
• Its based on objects and classes as
constructs used to develop software systems
• A class consists of attributes that store data
and methods that modify that data
• Communication between objects is by
message passing
• Class is a structuring mechanism that
provides a framework that can be can be
used to represent problem and transform it
in small steps continuous to a computer
program.
Object oriented visualization
OO makes it easy to visualize how the
system was developed since the
objects/classes in requirements
engineering/Analysis are transformed
into objects/classes in design and
then transformed into program
objects/classes. You are able to see
big picture of each phases
objects/classes diagrams as well as
detailed picture of each of the
classes/objects.
Objects in the world
• An object is a thing and things can be classified into living or
non-living things everything is a thing or potential part of a
thing.
• Its possible to model systems as objects
• People think in terms of object- for example when going to
library to borrow books you think it terms of books, librarian,
borrowing, book tittles, authors which are objects, relations,
groups of interacting objects, or attributes of objects.
• Object oriented analysis uses constructs that we are familiar
with and are fundamental to our thinking. This making it
easier to understand and apply familiar constructs than
unfamiliar non-common constructs
• Traceability – OO ensures traceability because you should be
able to show a objects/class came from interviewing
customer/client (verbs/nouns in interview document). It was
presented in class diagram in requirements documents, that
was then transformed into a design (solution). This helps in
testing, verifying and validating.
Problem solving and OO ADP
To develop a software you need to
1. understand the problem
2. Understand how problem is solved
manually or by automation e.g. developing a
new system to replace a legacy system
3. Understand methods, languages, program
and development environments to be use
to solve and implement solution
4. Have skills and experience to perform
above tasks and implement solution in
programming language
Analysis and Design
1. To create best solution you need to follow
detailed analysis process of determining
project requirements (defining what
system is supposed to do) – understand
problem domain and representing it as non
ambiguous requirements – this phase is also
called requirements engineering.
2. Developing a solution that satisfies
requirements, Design is specifying it will be
done. – design phase enables leveraging SE
knowledge to design a solution by
transforming requirements to designs
Programming
Requires
1. Analyzing problems
2. Identifying key
components
3. Modeling data and
processes
4. Writing the program
Programming Language
Consists of:
1. Key words
2. Syntax for combining key words
into program statements and
statements into blocks of
statements and blocks into
programs
3. Semantics – the meaning of
keywords, statements, group of
statements and programs
Unified modeling language (UML)
A Modeling language that has diagrams/models for
representing user and system requirements and
provides a means of developing an abstract
solution (design) that satisfies requirements and
that can be directly coded.
1. Its most widely used modeling language for
software analysis and design
2. It a standard modeling language so should not
include your own symbols and diagrams – the
standard is maintained by object management
group
3. Its being continuously improved so UML has
several versions
4. Its has been adapted in engineering disciplines
as SysUML
Structured programming
1. Eliminated go to statement
2. Introduces three simple program structuring
mechanisms that help reduced program
complexity - sequence, selection and iteration
3. science and technology Parsimony principle
states that you should select the most simple
approach that able to do something and not
more complex approaches all other factors
being constant.
4. Simplicity is principle for reducing complexity
used in all software and engineering methods –
parsimony when developing complex software
system makes the development process
reliable and verifiable and validatable
Structured programming (SP) constructs
Structured programming consists fo
three constructs: Sequence, iteration
and selection
Sequence - instructions are executed
one after another in a sequences
Statement1
Statement 2
Statement 3

Statement n.
Structured programming (SP) constructs

Statement1

Statement2

……

StatementN
SP Sequence activity diagram
Don’t confuse SP sequence UML
activity diagram and UML Sequence
diagram
UML can be used to represent may
types system some of them with
same names as UML diagrams
INSERT DIAGRAM
Structured programming selection
Java has three selection statements
If (conditional statement) {
statement to execute if condition true
}
If (conditional statement) {
Statement/s to execute if condition true
} else {
Statement/s to execute if condition
false
}
Structured programming selection
Input salary
If (salary>12000) {
Display “greater than”
}
Activity diagram that asks use to
enter salary and displays greater
that if salary is greater than
12,000
UML IF ACTIVITY DIAGRAM

input salary

display greater
N>12000
than

N<12000
Input salary
If (salary>12000) {
Display “greater than 12000”
If (salary>35000)
display greater than 35000
}
}
Nest if salary activity diagram

Inp ut salary

Sala ry>12 00 0

disp lay greater t han


12000

Sala ry<-12 00 0

Sala ry>35 00 0

disp lay greater t han


35000
Structured programming selection …
Switch statement
Switch (conditionstatement) {
Case 1:
Statement/s to execute if case1 true
Break;
Case 2:
Statement/s to execute if case2 true
Break;
……
Case n:
Statement/s to execute if casen true
Break;
default:
Statement/s to execute if none of cases is true
}
Switch activity diagram

Case a true case a action break

False

Case b True case b action break

False

True
case z action break
Case z

False

default action
Structured programming Iteration
Java provides iteration statements
also called repetition or looping
statement that enables program to
perform statements repeatedly as
long as conditionalstatement is
true.
while statements and for
statements
For loop activity diagram

initialize
counter=1 counter

Counter<=10 display counter value counter=counter+1

Counter>10

Determine
whether loops
should continue
While loop activity diagram

Counter=1

display counter value

add 1 counter counter=counter+1

determine Counter<=10

looping
shouldnt
continue

Counter>10
Object oriented programming
OO Program consists of a series of
objects that communicate through
message passing
Class group of objects that share some
properties (methods and attributes). E.g.
book a class and dietel book is an object.
Object an instance of class
Attributes represent data about state of
objects
Methods perform operations on object
attributes
UML activity diagrams
They are to model organization
activities, program processses and
design modules

UML activity diagram symbols


Salary exercise
Draw an activity diagram that asks
user to enter salary and displays if:
• Salary is greater than
12000(>12000)
• greater than 5000 and Less than
12000 (salary>5000 and <12000)
• Less or equal to 5000 (<=5000)
Individual mulitIFSelect exercise
1. Draw an activity diagram that asks user to
enter salary and displays if:
• >=1000000 displays millions
• >=100000 displays hundred thousands
• >=1000 displays thousands
• >=100 displays hundreds
• >=10 displays tens
• <10 displays ones and less
1. Write a java program
Copy your activity diagram and program in world
and submit as a single file
Submit blackboard BY 6-6-2023 linkname
multiIFselectWK4
Salary UML activity diagram

Salary<-12000

The activity diagram is a design so usually no program specific information


is included
UML nested IFactivity diagrams display to add
5 total if n>=10 and 5 When n>=5 and <10

n>=10

n<10
total =total +10

n>=5 total=total+5
````
Submission Exercises
1. Draw an activity diagram for the following nested
for statement
Input prodik
For(int i=1;i<8;i++) {
display I
For(int k=1;k<8;k++) {
prodik=i*k
Display prodik
{
}
Practice Exercises
1. Draw an activity diagram that asks
user to enter an integer n greater
than 1 and sums the squares of first
20 numbers.
2. Draw an activity diagram for if else
statement. The activity diagram ask
the user to enter a number and
displays if number is less or equal (<=)
or greater.
3. Draw activity diagram for switch
statement without break statement
but with default

You might also like