COSC 1P03 Data Structures and Abstraction 2.1 Software Development The leadership instinct you are born with is the backbone. You develop the funny bone.

Slides:



Advertisements
Similar presentations
Making the System Operational
Advertisements

Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view class.
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Programmer-defined classes Part 2. Topics Returning objects from methods The this keyword Overloading methods Class methods Packaging classes Javadoc.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
Software Lifecycle A series of steps through which a software product progresses Lifetimes vary from days to months to years Consists of –people –overall.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
C++ fundamentals.
Chapter 6: Functions.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Chapter 6: User-Defined Functions I Instructor: Mohammad Mojaddam
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
COSC 1P03 Data Structures and Abstraction 4.1 Abstract Data Types The advantage of a bad memory is that one enjoys several times the same good things for.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Software Life Cycle Requirements and problem analysis. –What exactly is this system supposed to do? Design –How will the system solve the problem? Coding.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
Object-Oriented Modeling Chapter 10 CSCI CSCI 1302 – Object-Oriented Modeling2 Outline The Software Development Process Discovering Relationships.
Classes CS 21a: Introduction to Computing I First Semester,
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
1 Introduction Modules  Most computer programs solve much larger problem than the examples in last sessions.  The problem is more manageable and easy.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
Object Based Programming Chapter 8. 2 In This Chapter We will learn about classes Garbage Collection Data Abstraction and encapsulation.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
Static Methods. 2 Objectives Look at how to build static (class) methods Study use of methods calling, parameters, returning values Contrast reference.
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
COSC 1P02 Intro. to Computer Science 8.1 Cosc 1P02 Only those who attempt the absurd can achieve the impossible.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
MIT AITI 2004 – Lecture 13 Abstract Classes and Interfaces.
Chapter 5 Introduction to Defining Classes
1 Object-Oriented Design Now we can extend our discussion of the design of classes and objects Chapter 6 focuses on: software development activities determining.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 11 Object-Oriented.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Object-Oriented Design.
COSC 1P02 Data Structures and Abstraction 2.1 Cosc 1P02 Binary Files & Persistent Objects “For myself, I am an optimist--it does not seem to be much use.
 2005 Pearson Education, Inc. All rights reserved. 1 Introduction to Classes and Objects.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Session 7 Introduction to Inheritance. Accumulator Example a simple calculator app classes needed: –AdderApp - contains main –AddingFrame - GUI –CloseableFrame.
CSC 480 Software Engineering PSP Project 2 August 27, 2004.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
AP Java Ch. 4 Review Question 1  Java methods can return only primitive types (int, double, boolean, etc).
Fusion Design Overview Object Interaction Graph Visibility Graph Class Descriptions Inheritance Graphs Fusion: Design The overall goal of Design is to.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Object Based Programming Chapter 8. 2 Contrast ____________________ Languages –Action oriented –Concentrate on writing ________________ –Data supports.
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Copyright © 2012 Pearson Education, Inc. Chapter 4 Writing Classes : Review Java Software Solutions Foundations of Program Design Seventh Edition John.
Software Configuration Management
Chapter 6: User-Defined Functions I
Chapter 11 Object-Oriented Design
Chapter 3: Using Methods, Classes, and Objects
About the Presentations
Object Based Programming
Topics Introduction to File Input and Output
CSE 1020:Programming by Delegation
Topics Introduction to File Input and Output
Presentation transcript:

COSC 1P03 Data Structures and Abstraction 2.1 Software Development The leadership instinct you are born with is the backbone. You develop the funny bone and the wishbone that go with it. Elaine Agather

COSC 1P03 Data Structures and Abstraction 2.2 Software Development  Phases  Analysis  problem statement  requirements specification  system analysts  inputs and outputs  system model  Design  class specifications  architectural plan  system designers  Coding  coding according to specifications  programmers

COSC 1P03 Data Structures and Abstraction 2.3 Phases of Software Development

COSC 1P03 Data Structures and Abstraction 2.4  Testing  unit level testing  integration testing  system testing  testers  Debugging  based on test results  Production  trainers  technical support  Maintenance  releases  versions  Documentation  user documentation  technical documentation  technical writers

COSC 1P03 Data Structures and Abstraction 2.5 Case Study: Grade Report System  Problem statement  Analysis  develop requirements specification  refine statement  determine inputs and outputs  Graphical User Interface (GUI)  report formats  develop model  select object/classes  determine relationships

COSC 1P03 Data Structures and Abstraction 2.6 Problem Statement

COSC 1P03 Data Structures and Abstraction 2.7 Analysis  Refinement  marking scheme?  Inputs  course name  bases and weights for each piece of work  number of students  for each student:  student #, name and mark for each piece of work  class list  text file with class (student) information  mark data arrives over time  requires persistence  binary file  application to create a new course  application to enter/update mark data final mark computation application

COSC 1P03 Data Structures and Abstraction 2.8 Analysis.  Outputs  forms  marking scheme info  student info  course info  Reports  final mark report  for each student student number and final grade  summary statistics: course average  others?

COSC 1P03 Data Structures and Abstraction 2.9 Refined Problem Statement

COSC 1P03 Data Structures and Abstraction 2.10 Marking Scheme Display Form

COSC 1P03 Data Structures and Abstraction 2.11 Student Display Form

COSC 1P03 Data Structures and Abstraction 2.12 Course Display Form

COSC 1P03 Data Structures and Abstraction 2.13 Grade Report Format

COSC 1P03 Data Structures and Abstraction 2.14 Grade Report Format

COSC 1P03 Data Structures and Abstraction 2.15 Mark Report Format

COSC 1P03 Data Structures and Abstraction 2.16 Analysis..  Object/Classes  nouns in problem specification  candidate objects  eliminate values, duplicates and irrelevant entities  Model  relationships between classes  multiplicity

COSC 1P03 Data Structures and Abstraction 2.17 Selecting Candidate Objects A system is needed to keep track of the marks for students in a course. A class list of student name and number is available at the start of the course. Throughout the term, marks are recorded for students in the course in each of a number of pieces of work (e.g. assignments, tests, exam). When the course is complete, a final mark is computed for each student based on their marks in these pieces of work according to a marking scheme and a course average is computed. The marking scheme defines, for each piece of work, its base mark and weight towards the final mark.

COSC 1P03 Data Structures and Abstraction 2.18 Candidate Objects and Identified Objects

COSC 1P03 Data Structures and Abstraction 2.19 Analysis Model

COSC 1P03 Data Structures and Abstraction 2.20 Software Development Fact is, you saved my life today. But I'd rather it was my fault I got shot than your fault I didn't. Jack Beauregard to Nobody (My Name is Nobody : 1973)

COSC 1P03 Data Structures and Abstraction 2.21 Design  Classes identified in analysis  Additional classes  implementation classes  main class  Goal: detailed class descriptions  CRC card  class  responsibilities  collaborators  four cards, one per class  do responsibilities for knowing first  then responsibilities for doing  fill in collaborators

COSC 1P03 Data Structures and Abstraction 2.22 Analysis Model

COSC 1P03 Data Structures and Abstraction 2.23 CRC card

COSC 1P03 Data Structures and Abstraction 2.24 Responsibilities for Knowing  Nouns in problem statement  keep values  others from analysis/experience  Assign each to a class  consider real-world  don’t duplicate in another class  Example:  student number and marks in Student  bases and weights in MarkingScheme  average final mark in Course

COSC 1P03 Data Structures and Abstraction 2.25 Selecting Values A system is needed to keep track of the marks for students in a course. A class list of student name and number is available at the start of the course. Throughout the term, marks are recorded for students in the course in each of a number of pieces of work (e.g. assignments, tests, exam). When the course is complete, a final mark is computed for each student based on their marks in these pieces of work according to a marking scheme and a course average is computed. The marking scheme defines, for each piece of work, its base mark and weight towards the final mark.

COSC 1P03 Data Structures and Abstraction 2.26 Field Values

COSC 1P03 Data Structures and Abstraction 2.27 Responsibilities for Doing  Verbs (actions) in problem statement  keep relevant  Assign each to a class  who knows data?  collaboration to access data  Example  computing final mark  Student and MarkingScheme  generate report  Course and Report  average  Course  CRC cards

COSC 1P03 Data Structures and Abstraction 2.28 Selecting Candidate Actions

COSC 1P03 Data Structures and Abstraction 2.29 Identified Tasks

COSC 1P03 Data Structures and Abstraction 2.30

COSC 1P03 Data Structures and Abstraction 2.31

COSC 1P03 Data Structures and Abstraction 2.32 Design Model

COSC 1P03 Data Structures and Abstraction 2.33 Architecture  Main class  identified class or new  Course could be part of something larger  could have applications involving a course  new class ( FinalGrades )  Collaborations  who controls interaction?  i.e. which is client which is server, source of resource  Architectural plan  persistence  various applications access information over time  all classes persistent  sequential processing  Process students in order.

COSC 1P03 Data Structures and Abstraction 2.34 Detailed Design  Class design  responsibility for knowing  instance variables  responsibility for doing  methods  Interfaces  class specifications including method declarations  methods identified as “doing” in CRCs  accessor and updater methods  fill in parameter types  Generalization  design for future use  Forms and Reports  Can be represented by Classes?

COSC 1P03 Data Structures and Abstraction 2.35 Interfaces  Specification for classes  constants and method headers only  No implementation  cannot create objects of interface type  create objects of implementation classes  Defines a type  can declare variables of interface type  can assign objects of any implementation type  subtype  Can be compiled  can be referenced in other classes without an implementation

COSC 1P03 Data Structures and Abstraction 2.36

COSC 1P03 Data Structures and Abstraction 2.37 Package Interface specificatio n Defines the: Interface specification Defines the: -object -methods -constants Defines an interface object type Implementation of Object subtype 1 Implementation of Object subtype 2 Other classes interact package abc; import whatever.*

COSC 1P03 Data Structures and Abstraction 2.38 Class Design  Interface Course  accessor methods  updater methods?  other methods  Interface Student  accessor methods  updater methods?  other methods

COSC 1P03 Data Structures and Abstraction 2.39 Course Design package Student_Records; public interface Course { public String getCourseName ( ); public MarkingScheme getScheme ( ); public int getNumStd ( ); public double getCourseAve ( ); public void doRecordMarks ( ); public void doUpdateMarks ( ); public void calcFinalGrades ( ); public void doReport ( ); } // Course All classes in Student_Record s will belong to the same unit. Defines a class specification. Defines only the visible portion of the object, instance variables and constructors are not specified. Mark update application, not part of grade report. Produces the Student Grades Report.

COSC 1P03 Data Structures and Abstraction 2.40 Student Design Student is responsible for calculating its final mark based on the marking scheme. The marking scheme is passed so student knows about it. Used to extend the application to a complete grade management system package Student_Records; public interface Student { public String getStNum ( ); public String getName ( ); public double getMark ( int num ); public double getFinalMark ( ); public void calcFinalMark( MarkingScheme scheme ); public void update ( MarkingScheme scheme ); } // Student

COSC 1P03 Data Structures and Abstraction 2.41  Interface MarkingScheme  accessor methods  updater methods  other methods  Interface Work  accessor methods  updater methods  other methods

COSC 1P03 Data Structures and Abstraction 2.42 MarkingScheme Design CalcFinalMark, in turn calls apply with the student object. Easier since most of the info is in marking scheme. The return will be the students final mark. The students marks and the work will likely be an array, thus we get a position which corresponds to a work item. e.g. Assignment.

COSC 1P03 Data Structures and Abstraction 2.43 Work Design Simple class representing the individual pieces of work. The work name is/will be set during construction.

COSC 1P03 Data Structures and Abstraction 2.44 Implementation  Coding by programmers  responsible for a specific class  implementation can be done in any order  May be multiple applications in system  e.g. Student Records System  new course setup  mark entry  mark reporting  final grade computation with report*

COSC 1P03 Data Structures and Abstraction 2.45 Coding  Contract  interface provides specification  interfaces for other classes  collaborators – what can be used  Implementation Classes  implements clause  requirements  Instance variables  from “knowing” in CRCs  others as needed for implementation  Methods  As required by the interface  Additional support is provided by private local methods.

COSC 1P03 Data Structures and Abstraction 2.46 Class MarkingSchemeImpl  Persistent  Instance variables  Constructor  for initial setup  Identified methods  accessor/updater  apply  weighted sum  display  Support ( private ) methods

COSC 1P03 Data Structures and Abstraction 2.47 Class StudentImpl  Persistent  Represents single student  Instance variables  Constructor  initial setup  initializes marks ( -1 )  Identified methods  accessor/updater  calcFinalMark  delegates to MarkingScheme  update  for mark update application

COSC 1P03 Data Structures and Abstraction 2.48 Class WorkImpl  Persistent  Instance variables  Constructor  initializes fields  For new course  Identified methods  accessor/updater

COSC 1P03 Data Structures and Abstraction 2.49 Class CourseImpl  Persistent – contains students and marking scheme  Instance variables  Constructor  initial setup only, creation of the object, afterward it becomes persistent.  initializes classAve ( -1 )  Identified methods  accessor/updater  doUpdateMarks, doMarkReport  other applications  calcFinalGrades  process each student  Writes a detail line to the report  compute average  write summary (gets average using course accessor)  display  Support methods

COSC 1P03 Data Structures and Abstraction 2.50 Class MarkingSchemeForm  Visibility  marking scheme data  GUI for marking scheme display  Not persistent  Instance variables  Constructor  builds form  Methods  Local methods

COSC 1P03 Data Structures and Abstraction 2.51 Main class ( FinalGrades )  Object creation  All persistent object are assumed to exist  The course object is read from disk.  Course object will be modified (average grade) so this is a file update (1 record)  Course object does work  Write updated Course object (file)  Cleanup

COSC 1P03 Data Structures and Abstraction 2.52 Class CourseForm  Visibility  course data  GUI for course information display  Not persistent  Instance variables  Constructor  builds form  Methods  Local methods

COSC 1P03 Data Structures and Abstraction 2.53 Class FinalGradeReport  One of the Report types  Not persistent  Instance variables  Constructor  initializes report on ReportPrinter  Identified methods  writeDetailLine  writeSummary  must use accessor to get average (cannot change method header)  Support methods

COSC 1P03 Data Structures and Abstraction 2.54 Testing  Class stubs  collaborator classes?  class stub implements same interface so is pluggable  method stubs  Test harness  replaces main class for testing  perform desired tests  test all methods and constructors  repeatable  Integration testing & system test  Test sets  sets of test data to test all possibilities  test ends of ranges  0, 1 and other number of students  0, full and other marks  predicted output  prepare ahead of time and keep on file

COSC 1P03 Data Structures and Abstraction 2.55 Debugging, Production & Maintenance  Debugging  apply program to test data  when unexpected output, re-code, re-design and/or re- analyze  System.out.println  Production  when satisfies all tests, release to users  Maintenance  correction of errors found in field (hopefully few)  addition of new features  re-analyze etc.  change of specification  re-analyze etc.

COSC 1P03 Data Structures and Abstraction 2.56 Marking Scheme Test public class MarkingSchemeTest { private MarkingScheme scheme; // object to test private Student aStudent; // student stub object for tests public MarkingSchemeTest ( ) { Work[] work; work = new Work[4]; work[0] = new WorkImpl("W1",15,25); work[1] = new WorkImpl("W2",15,25); work[2] = new WorkImpl("W3",15,25); work[3] = new WorkImpl("W4",15,25); scheme = new MarkingSchemeImpl(work); aStudent = new StudentStub(); }; // constructor private void run ( ) { double mark; // computed mark scheme.display(); System.out.println("Number of pieces of work: "+scheme.getNumWork()); for ( int i=0 ; i<scheme.getNumWork() ; i++ ) { System.out.println("Work"+i+": "+scheme.getName(i)+", " +scheme.getBase(i)+", "+scheme.getWeight(i)); }; mark = scheme.apply(aStudent); System.out.println("Calculated mark: "+mark); }; // runTest aStudent is implemented as a stub. Looks like aStudent, but is functionally brain dead. When aStudent is passed to the apply method, calls to aStudent’s methods will produce pre- determined responses.

COSC 1P03 Data Structures and Abstraction 2.57 Student Stub public class StudentStub implements Student, Serializable { private static final long serialVersionUID = L; public StudentStub ( ) { }; // constructor public String getStNum ( ) { System.out.println("Student.getStNum() called"); return "stdNum"; }; // getStNum public String getName ( ) { System.out.println("Student.getName() called"); return "StdName"; }; // getName public double getMark ( int num ) { System.out.println("Student.getMark("+num+") called"); if ( num == 0 ) { return -1; } else { return num * 5; } }; // getMark etc. etc. Constructor creates an object with no functionality, i.e. no instance variables. Write a simple message to system out so the tester knows what is going on. Method call expects a return value, so return something which is consistent with the type. All other methods get implemented in a similar way.

COSC 1P03 Data Structures and Abstraction 2.58 The End