OOP Week 1 Overview of Course 0
OOP Week 1 Overview of Course 0
OR
Bobs Bank
Bobs Bank
Problem
Given the current rate of interest, how
much will all my customers have in their
deposit accounts at the end of…
1,2,3,…N years?
We want to write a program to solve
this problem.
Computers are a bit dim!
We have to detail precisely the
instructions… There is no Mr Data from
Star Trek here, no computer
understands English!
We must be able to figure out how to
solve the problem first (on paper)
before we attempt to write a computer
program to tackle the task.
Developing software: the traditional approach
The Water Fall Method
Analysis and
Specification
Design
Implementation
Testing
Installation
Operation and
Maintenance
The Waterfall model
Many people use “code and fix”, which
means you sit at your computer, code
and correct bugs when or if they are
encountered.
This is fine if your program is small.
For programs with thousands of lines of
code, you will have to do things away
from the computer
Waterfall Model continued
The standard Waterfall Model for systems development
is an approach that goes through the following steps:
Document System Concept (what am I going to do)
Identify System Requirements and Analyze them
Analysis: what is it that I am going to build?
Break the System into Pieces (Architectural Design)
Design Each Piece (Detailed Design)
How am I going to achieve this?
Code the System Components and Test them
Individually (Coding, Debugging, and Unit Testing)
Sometimes this is called the implementation phase
Waterfall Method continued
Integrate the Pieces and Test the System
(System Testing)
Deploy the System and Operate It
Maintain the system updating the system
when the need arises
Bring out later/better editions
This model is widely used on large
governmental systems, particularly by the
Department of Defense (DOD).
The Waterfall Model
One of the draw backs of the Waterfall
Model is that each stage in the cycle (or
process) must be completed before
moving on to the next stage.
This can cause timing problems i.e. one
simply does not have enough time to
complete each task.
Are there other (and hopefully better)
ways of doing things?
Developing software: the modern approach (RAD)
RAPID APPLICATION DEVELOPMENT (RAD)
Building
Analysis
Prototypes
Initial Final
Planning Product
Testing and Reviewing
Quality Prototypes
Assurance
Rapid Application Development
(RAD)
DEFINITION
a software development process that
allows usable systems to be built in as
little as 60-90 days, often with some
compromises.
Drawback: the final product often does
not meet the exact requirements
originally requested, there is a trade off in
requirements.
RAD continued
PRINCIPLES BEHIND THE DEFINITION
int main() {
double interest;
double deposit;
double value;
int years;
cout << "hello, please enter the current interest rate : ";
cin >> interest;
cout << "now enter the number of years 1,2 or 3 ahead to calculate : ";
cin >> years;
if (years == 1) {
value = deposit*(1 + interest);
cout << "Value after " << years << " year is " << value << endl;
}
else
if (years == 2) {
value = deposit*(1 + interest)*(1 + interest);
cout << "Value after " << years << " years is " << value << endl;
}
else
if (years == 3) {
value = deposit*(1 + interest)*(1 + interest)*(1 + interest);
cout << "Value after " << years << " years is " << value << endl;
}
else
{
cout << "Invalid number of years entered" << endl;
}
//this is Bank1.cpp
return 0;
}
Demo
Please see hello1.cpp
Bank1.cpp
and explain
Show
Payroll.cpp (which is a bit advanced for
week 1, look at others in folder first)
Practice, Practice, Practice
Computer programming is more like
Learning a musical instrument
Learning to play a new sport
Driving a car
It is an active process
It is an incremental process
It constantly builds from previous knowledge
TRY NOT to get left behind as it is VERY hard
to catch up!
Why, What, How, Where and When
Why are you learning to program?
What will you learn?
How will you learn?
How will you be assessed?
Where will you learn?
When will you learn?
Why are you learning to Program?
Or what’s in it for me?
Functions/procedures
C/C++ de-facto industry standard programming
language.
It works on the network here (I hope! We had
problems last year!)
Why C++
Friendly development environment and good
debugging tools.
Cheap for student edition
C++ rather than C because I/O friendlier,
easier introduction of functions and strings.
Supports Object Oriented Programming, C
does not.
Java is even nicer, does away with pointers
(hides their usage somewhat)
Procedural paradigm
Sequential
Program runs from top down, one command
performed, then move onto the next
Selection
Can make choices in a program
Iteration
Can repeat certain parts of your program which
are only terminated when certain criteria are
satisfied
OO paradigm
Encapsulation
Polymorphism
Inheritance
solution to a problem in an
unambiguous way.
You will learn how to verify the