COMP 121 Week 7: Object-Oriented Design and Efficiency of Algorithms.

Slides:



Advertisements
Similar presentations
1 Software Testing and Quality Assurance Lecture 13 - Planning for Testing (Chapter 3, A Practical Guide to Testing Object- Oriented Software)
Advertisements

SEP1 - 1 Introduction to Software Engineering Processes SWENET SEP1 Module Developed with support from the National Science Foundation.
Copyright © Texas Education Agency, Computer Programming Software Life Cycle.
Problem Solving #1 ICS Outline Review of Key Topics Review of Key Topics Example Program Example Program –Problem 7.1 Problem Solving Tips Problem.
Object-Oriented Analysis and Design
Liang,Introduction to Java Programming,revised by Dai-kaiyu 1 Chapter 10 Object-Oriented Modeling.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Software Development Software Life Cycle UML Diagrams.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Fall 2007CS 2251 Software Engineering Intro. Fall 2007CS 2252 Topics Software challenge Life-cycle models Design Issues Documentation Abstraction.
1 Lecture 5 Introduction to Software Engineering Overview  What is Software Engineering  Software Engineering Issues  Waterfall Model  Waterfall Model.
Extreme Programming--a “New” Process Model Extreme Programming-- a “New” Process Model.
1 Object-Oriented Design. 2 Objectives F To become familiar with the process of program development. F To the relationship types: association, aggregation,
Chapter 1 Software Engineering. Homework ► Read Section 2.2 (pages 79-98) ► Answer questions: ► 7, 8, 11, 12, & 13 on page 134. ► Answer on paper, hand.
Software Engineering Principles and C++ Classes
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Xtreme Programming. Software Life Cycle The activities that take place between the time software program is first conceived and the time it is finally.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
The Software Product Life Cycle. Views of the Software Product Life Cycle  Management  Software engineering  Engineering design  Architectural design.
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
Chapter 17 – Object- Oriented Design. Chapter Goals To learn about the software life cycle To learn about the software life cycle To learn how to discover.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented Design.
Systems Analysis and Design in a Changing World, Fifth Edition
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
COMP 121 Week 7: Object-Oriented Design and Efficiency of Algorithms.
Understand Application Lifecycle Management
Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established.
1 Object orientation. 2 What benefits does OO give? Primarily –Encapsulation (Associates data & operations) –Types & specialisation –Software re-use.
Software Life Cycle Requirements and problem analysis. –What exactly is this system supposed to do? Design –How will the system solve the problem? Coding.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
Object-Oriented Modeling Chapter 10 CSCI CSCI 1302 – Object-Oriented Modeling2 Outline The Software Development Process Discovering Relationships.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
Review: Cohesion and Coupling, Mutable, Inheritance Screen Layouts Software methodologies – Extreme Programming Object-Oriented Design – CRC Cards - UML.
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Chapter 12 – Object-Oriented Design.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
5 Systems Analysis and Design in a Changing World, Fifth Edition.
Object-Oriented Analysis and Design. Lesson 1: Introduction to Software Engineering.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
CIS 112 Exam Review. Exam Content 100 questions valued at 1 point each 100 questions valued at 1 point each 100 points total 100 points total 10 each.
CS 151: Object-Oriented Design September 5 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Chapter 17 – Object- Oriented Design. Chapter Goals To learn about the software life cycle To learn about the software life cycle To learn how to discover.
Data Structures Using C++ 2E
ITEC324 Principle of CS III Chapter 2 (Horstmann’s Book) – Part 1 The Object-Oriented Design Process Hwajung Lee.
Chapter 8 Testing. Principles of Object-Oriented Testing Å Object-oriented systems are built out of two or more interrelated objects Å Determining the.
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.
INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify.
Fall 2007 Week 9: UML Overview MSIS 670: Object-Oriented Software Engineering.
Chapter 2 (Horstmann’s Book) – Part 1 The Object-Oriented Design Process Hwajung Lee.
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Chapter 12 – Object-Oriented Design.
Software Development. The Software Life Cycle Encompasses all activities from initial analysis until obsolescence Analysis of problem or request Analysis.
Software Development Life Cycle. The Software Life Cycle  Encompasses all activities from initial analysis until end of work  Formal process for software.
Software Development.
Chapter 12 – Object-Oriented Design
CHAPTER
Lecture 3 Prescriptive Process Models
Chapter 1: Introduction to Systems Analysis and Design
Computer Programming Software Life Cycle.
Roberta Roth, Alan Dennis, and Barbara Haley Wixom
Chapter 11 Object-Oriented Design
About the Presentations
Advanced Java Programming
Domain Class Diagram Chapter 4 Part 2 pp
Chapter 1: Introduction to Systems Analysis and Design
Chapter 12 – Object-Oriented Design
Algorithms and Problem Solving
Chapter 1: Introduction to Systems Analysis and Design
ITEC324 Principle of CS III
Presentation transcript:

COMP 121 Week 7: Object-Oriented Design and Efficiency of Algorithms

Objectives Learn about the software life cycle Learn how to discover new classes and methods Understand the use of CRC cards for class discovery Be able to identify inheritance, aggregation, and dependency relationships between classes

Objectives (cont’d) Learn to use UML class diagrams to describe class relationships Learn how to use object-oriented design to build complex programs Learn how to analyze the efficiency of an algorithm

Software Life Cycle Encompasses all activities from initial analysis until obsolescence Formal process for software development –Describes phases of the development process –Gives guidelines for how to carry out the phases

Development Process AnalysisDesignImplementationTestingDeployment

Analysis Phase Defines what the project is suppose to do Not concerned with how the program will accomplish tasks What is the output of the Analysis Phase?

Design Phase Plans system implementation Identifies Classes, Methods Needed What is the output of the Design phase?

Implementation Phase Write and compile the code Implement classes and methods discovered in the design phase Output?

Testing Phase Run tests to verify the program works correctly Output: a report of the tests and their results, test coverage

Deployment Phase Software installed and used for its intended purpose

The Waterfall Model

Sequential process of analysis, design, implementation, testing, and deployment When rigidly applied, does not work well!

The Spiral Model Breaks development process down into multiple phases Early phases focus on the construction of prototypes Lessons learned from development of one prototype can be applied to the next iteration Problem: can lead to many iterations, and process can take too long to complete

The Spiral Model

Extreme Programming Strives for simplicity Removes formal structure Focuses on best practices Realistic planning Small releases MetaphorSimplicityTestingRe-factoring

Extreme Programming (cont’d) Focuses on best practices –Pair programming –Collective ownership –Continuous integration –40-hour week –On-site customer –Coding standards

Test Driven Development

Typical Sequence of Steps: –Create a new test case –Write enough code to fail the test –Run the tests and watch the new test fail –Write the simplest code that will pass the new test –Run the tests and watch all the tests pass –Remove duplication –Rerun the tests

Test Driven Development

Discovering Classes Class represents set of objects with the same behavior –Entities with multiple occurrences in problem description are good candidates for objects –Identify commonalities –Design classes to capture commonalities Represent some entities as objects, others as primitive types –Should we make a class Address or use a String? Not all classes can be discovered in analysis phase Some classes may already exist?

CRC Cards Class, Responsibility, Collaboration Used to start brainstorming about an object-oriented design Responsibilities are operations performed by the class Collaborators are other classes involved in performing these operations

CRC Cards (cont’d)

Relationships Between Classes InheritanceAggregationDependency

Inheritance Is-a relationship Relationship between a more general class (superclass) and a more specialized class (subclass) Example: Every savings account is a bank account Can be overused: Should a Tire be a subclass of Circle? Design Principle: Favor composition over inheritance

Aggregation Has-a relationship Objects of one class contain references to objects of another class Use an instance variable A tire has a circle as its boundary: class Tire {... private String rating; private Circle boundary; }

Aggregation (cont’d) Every car has a tire (in fact, it has multiple tires) class Car extends Vehicle {... private Tire[] tires; }

UML Notation

Dependency Uses relationship Example: Many applications depend on the Scanner class to read input Aggregation is a stronger form of Dependency BlueJ only shows Uses relationships

UML Diagram Example

Class Diagram - BlueJ

Five-Part Development Process Gather requirements Use CRC cards to find classes, responsibilities, and collaborators Use UML diagrams to record class relationships Use javadoc to document method behavior Implement your classes

Discussion Questions? How does this development process apply to your lab assignments? –Gather requirements –Use CRC cards to find classes, responsibilities, and collaborators –Use UML diagrams to record class relationships –Use javadoc to document method behavior –Implement your code

Requirements The requirements are defined in the lab write-up that is handed out –If they are unclear, you should get clarification from the customer (me!) From the requirements, begin thinking about the classes, responsibilities, and relationships –It may be helpful to do this BEFORE you look at the code that was provided

CRC Cards Discover classes –Most, if not all, classes are already determined Discover responsibilities –Relate the method names to the verbs in the requirements Describe relationships –Consider whether there are other relationships between the classes besides those already established

Javadoc Examine the javadoc that is included with the lab –Consider how the methods relate to the responsibilities on the CRC cards –Consider whether there are other methods that should be included

Implementation Implement the code using test-driven development

Summary The life cycle of software encompasses all activities from initial analysis until obsolescence The waterfall model describes a sequential process of analysis, design, implementation, testing, and deployment The spiral method describes an iterative process in which design and implementation are repeated Extreme Programming is a methodology that strives for simplification and focuses on best practices In object-oriented design, you discover classes, determine the responsibilities of the classes, and describe the relationships between classes A CRC card describes a class, its responsibilities, and its collaborating classes

Summary (cont’d) Inheritance (the is-a relationship) is sometimes inappropriately used when the has-a relationship would be more appropriate Aggregation (the has-a relationship) denotes that objects of one class contain references to objects of another class Dependency is another name for the uses relationship UML uses different notations for inheritance, interface implementation, aggregation, and dependency Use javadoc comments to document the behavior of classes

Questions?

Efficiency of Algorithms Difficult to get a precise measure of the performance of an algorithm or program Can characterize an algorithm by how the execution time increases as a function of the size of the input (asymptotic performance) –Big-O notation

Common Growth Rates

Growth Rate Functions

Growth Rate Table n O(1)11111 O(log n) O(n) O(n log n) x10 6 9x O(n 2 ) O(n 3 ) O(2 n ) x O(n!) 9x10 157

What is the Big-O of this algorithm for (int i=0; i<n; i++) for (int j=0; j<n; j++) System.out.println(i + “ “ + j);

What is the Big-O of this algorithm for (int i=0; i<n; i++) for (int j=0; j<2; j++) System.out.println(i + “ “ + j);

What is the Big-O of this algorithm for (int i=0; i<n; i++) for (int j=n-1; j>=i; j--) System.out.println(i + “ “ + j);

What is the Big-O of this algorithm for (int i=1; i<n; i++) for (int j=0; j<i; j++) if (j%i == 0) System.out.println(i + “ “ + j);

Questions?