Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object-Oriented Programming Developing an Application.

Similar presentations


Presentation on theme: "Object-Oriented Programming Developing an Application."— Presentation transcript:

1 Object-Oriented Programming Developing an Application

2 Cooperating Objects and Classes Object-oriented software systems consist of interacting objects Objects do things by sending messages to each other The data and behavior of an object are specified by its class A class contains variables for the data and methods for the behavior

3 Object-Oriented Analysis After the user requirements are established, we choose the classes that realize the desired behavior Classes may be built-in ( String, JButton, etc.) or programmer-defined ( Student, Employee, etc.)

4 Object-Oriented Design For each class, we specify the internal data structures and methods Within the methods, we show how objects interact to realize the desired behavior (using pseudocode)

5 Object-Oriented Implementation We code the classes, using either a bottom-up, top-down, or mixed approach Each class is thoroughly tested individually and then the components are integrated and tested further Development usually proceeds incrementally

6 Example: An Employee Management System The management wants a system that allows a user to enter each employee’s name, pay rate, and hours worked for each of five days. Users should be able to browse a list of employees for a given employee’s information. Users should be able to obtain an employee’s total pay for the week, using time and a half for overtime.

7 Analysis - Proposed User Interface

8 Analysis – Develop Prototypes A prototype is a trimmed-down or skeletal version of the full system A prototype gives the users an idea of what to expect without full functionality Might not have all the commands or each one working completely

9 Analysis – Choose Classes We use the model/view pattern The model classes manage the data The view classes present the data to the user and handle user interaction with the model

10 The Model Classes Employee represents and manages an individual employee’s data EmployeeModel represents and manages a list of employees

11 The View Classes EmployeeManagerView displays a list of employee names and the currently selected employee’s information; provides menus for commands EmployeeDialog allows the user to edit an employee’s information

12 Class Diagram Employee EmployeeDialog EmployeeModelEmployeeManagerView * 1 0..1 1 1 = contains just one 0..1 = contains zero or one * = contains zero or more

13 Design: The Attributes of the Employee Class Development is incremental, so work bottom-up, starting with Employee What information does an employee contain? –a name –the hours worked for each of five days

14 Constraints on the Attributes There are exactly five days Any hours over 8 * the number of days count for overtime Overtime pay is 1.5 * the regular pay rate Hours are whole numbers Pay rate is a real number

15 Design: The Behavior of the Employee Class get or set the name get or set the pay rate get or set the hours of each day get the total pay get the total hours worked

16 Other Useful Behavior obtain a string representation of an employee compare two employees for equality compare two employees for less than or greater than clone (copy) an employee transfer an employee to and from a file

17 Constructors A default constructor will initialize an employee’s data to reasonable values A second constructor allows the client to supply the data

18 Design: More Details Specify the interface (a set of public method signatures) Choose the data structures to represent the attributes Choose the algorithms for the methods Write a tester program to illustrate their use

19 The Employee Interface public Employee() public Employee(String name, double payRate, int[] hoursWorked) public String getName() public void setName(String newName) public double getPayRate() public void setPayRate(double newRate) public int getHours(int whichDay) public void setHours(int whichDay, int hours)

20 The Employee Interface public int getTotalHours() public double computePay() public String toString() public boolean equals(Object other) public int compareTo(Object other) public Object clone()

21 The Employee Interface static public final int MAX_DAYS = 5; static public final int MAX_REGULAR_HOURS = MAX_DAYS * 8; static public final double OVERTIME_RATE = 1.5;


Download ppt "Object-Oriented Programming Developing an Application."

Similar presentations


Ads by Google