Program Design: by Colt Stumpf Troy University Computer Science Club Technology Boot Camp 2011

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

PROGRAM DESIGN

By Colt Stumpf
Troy University Computer Science Club
Technology Boot Camp 2011
The Problem

 Where do I begin?
 What is the question?
 What are the variables?
 What functions are needed?
 How much time is needed?
 How many people are needed?
Where do I begin?

Do Not Do
 Begin righting code.
 Wait till the last minute.

Do
 Formulate a design
 Start immediately
What is a program design &
Why do I need it?
Program design gives us:
 A starting point
 An understanding of what is needed
 A plan to follow and direction on how to get
there
 A common ground for group projects
 Efficient code
What is the question?

Sample:
Your client wants a program that generates a
payroll report that will give individual pay and
total labor cost based on hours worked and rate
of pay. This program should also account for a 40
hour work week and all additional time is treated
as time and a half.
Greg makes $15/hr and worked 38hrs, Tammy
makes $15.75 and worked 47 hrs, and Jason
makes $13.45/hr and worked 33 hrs.
What are the variables?
 gPay This will hold the pay rate for Greg.
 gHrs This will hold the hours Greg worked.
 gTot This will hold the Greg’s total Pay.
 tPay This will hold Tammy’s pay rate.
 tHrs This will hold the hours Tammy worked.
 tTot This will hold the Tammy’s total Pay.
 jPay This will hold the pay rate for Jason.
 jHrs This will hold the hours Jason worked.
 jTot This will hold the Jason’s total Pay.
 WRKWK This will be a constant representing the 40 hr work week.
 totPay This will hold the total amount paid .
What functions are needed?

 Notice we have the same calculation done


several times.
 Separate into functionality.
 Main(); .
 WeeklyPay(pay/hr, hr/week, total/week);.
How much time and people are
needed?
 Study your design.
 Break the program into parts.
 If time is limited consider how many parts you
have and assign to other people.
 Starting as soon as possible reduces pressure
points in deadlines.
 Never overload your help.
Possible problems and
troubleshooting
 Check the logic of your algorithm these are
the most common errors .
 Make sure you answered the original
question.(shortest)
 Go through your flow chart function by
function and trace the data to the
error(longest )
 Syntax errors (your compiler becomes your
best friend here)
OOP Design

 What is OOP?
 How is it different from basic programming?
 How do I employ the same techniques as
before?
What is OOP?

Object-oriented programming (OOP) is
a programming paradigm using "objects"
– data structures consisting of data
fields and methods together with their
interactions – to design applications and
computer programs.
How is it different from
basic programming?
Programming techniques may include features
such as data abstraction, encapsulation,
modularity, polymorphism, and inheritance
Object oriented design
elements
 Change how everything is broken down.
 Generalization is the key to OOP.
 “Hide” data through encapsulation.
 Group things together with classes.
 Make code more efficient with inheritance.
 Create reusability with modularity.
OOP Question

Your client is a school board. They have 120


teachers and 3500 students. All of these
teachers teach more than one topic and there
is some overlapping. Write a program that
will place the students with the right teacher
in the right class.
Questions to consider

 What classes, attributes, and class methods


do we need?
 What data should be protected in a class from
other classes?
 How difficult is the program(ie time and
code)?
Classes
Person Class{ The Person class will be our parent
Status(teacher or student) class. Everything that is a person
must have these attributes.
Common information( ie ssn )
}
Person:Teacher class{ Inherited from the person class. The
Name Teacher class information should be
accessible by the class class, but the
Times available
student does not need any
Classes taught
information from the teacher/
}
Person:Student Class{ Inherited from the person class. The
Classes needed Student class and class class will
Times taking classes need to share information back and
} forth.
Class Class{
Class number The class class should be able to
Maximum students per class request any information from the
other classes, but is not a person and
Class time
therefore does not inherit these
Class Teacher
attributes.
}
What does OOP design do for
me?
 OOP corresponds more directly to human
thought process.
 Provides better data control
 Provides abstract data types(classes) in which
you may set the “rules” and treat the data
how you see fit.
 OOP is now the industry standard
programming paradigm.
Questions

You might also like