1 Chapter 6 Object-Oriented Software Design and Implementation.

Slides:



Advertisements
Similar presentations
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Advertisements

6-1 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s.
Problem Solving and Algorithm Design
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Problem Solving #1 ICS Outline Review of Key Topics Review of Key Topics Example Program Example Program –Problem 7.1 Problem Solving Tips Problem.
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Important Definitions Class: A structured data type that is used to represent an abstract data type (ADT) Class member: A components of a class. It can.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Slide 1 Systems Analysis & Design CS183 Spring Semester 2008 Dr. Jonathan Y. Clark Course Website:
Algorithms and Problem Solving
Slide 1 Chapter 7 Structural Modeling. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
1 Chapter 7 Inheritance, Polymorphism, and Scope.
Chapter 6 Problem Solving and Algorithm Design Nell Dale John Lewis.
Object-oriented Programming Concepts
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Software Engineering Principles and C++ Classes
Chapter 10 Classes Continued
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Domain Modeling (with Objects). Motivation Programming classes teach – What an object is – How to create objects What is missing – Finding/determining.
Chapter 9 High-Level Programming Languages: C++. Chapter Goals Describe the expectations of high level languages Distinguish between functional design.
Introduction To System Analysis and design
Object Oriented Software Development
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
1 Chapter-01 Programming Methodologies Procedural/Structured Design Objected-Oriented Design.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Slide 1 Structural Modeling Chapter 7. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
1 C++ Plus Data Structures Nell Dale Chapter 1 Software Engineering Principles Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore.
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.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Programming Life Cycle Problem analysisunderstand the problem Requirements definition specify what program will do High- and low-level designhow it meets.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Design.ppt1 Top-down designs: 1. Define the Problem IPO 2. Identify tasks, Modularize 3. Use structure chart 4. Pseudocode for Mainline 5. Construct pseudocode.
1 What is OO Design? OO Design is a process of invention, where developers create the abstractions necessary to meet the system’s requirements OO Design.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
No I/O is built into C++ l instead, a library provides input stream and output stream KeyboardScreen executing program istreamostream 1.
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
CSI 1340 Introduction to Computer Science II Chapter 1 Software Engineering Principles.
Chapter 1 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides.
CMSC 345 Fall 2000 OO Design. Characteristics of OOD Objects are abstractions of real-world or system entities and manage themselves Objects are independent.
Chapter 1 Software Engineering Principles. Problem analysis Requirements elicitation Software specification High- and low-level design Implementation.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Chapter 2 Principles of Programming and Software Engineering.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
Data Structures Using Java1 Chapter 1 Software Engineering Principles and Java Classes.
Object Based Programming Chapter 8. 2 Contrast ____________________ Languages –Action oriented –Concentrate on writing ________________ –Data supports.
Algorithms and Problem Solving
C++ Plus Data Structures
About the Presentations
Object Based Programming
Chapter 1 Software Engineering.
Algorithms and Problem Solving
Dale/Weems/Headington Program Input and the Software Design Process
Presentation transcript:

1 Chapter 6 Object-Oriented Software Design and Implementation

2 Chapter 6 Topics l Software Design Strategies l Objects and Classes Revisited l Object-Oriented Design l The CRC Card Design Process l Functional Decomposition l Object-Oriented Implementation l Packages l Ethics and Responsibility in the Computing Profession

3 Software Design Strategies FUNCTIONAL OBJECT-ORIENTED DECOMPOSITION DESIGN The solution is expressed in terms of objects (self-contained entities composed of data and operations on that data) that interact by sending messages to one another. Produces a hierarchy of objects. The problem is divided into more easily handled subproblems, the solutions of which together create a solution to the overall problem. Produces a hierarchy of tasks.

More about OOD l Languages supporting OOD include: Java, Smalltalk, Eiffel, CLOS, and Object-Pascal l A class defines the pattern used when instantiating an object of that type l A class generally contains private data and public operations (called methods)

Object-Oriented Design (OOD) Focus is on the entities (objects) in a problem Begins by identifying the classes of objects in the problem, and choosing appropriate operations on those objects Programs are collections of objects that communicate with (send messages to) each other Data plays a leading role; algorithms are used to implement operations on the objects and to enable interaction of objects with each other

OOD good with large software projects l Objects within a program often model real-life objects in the problem to be solved l The OOD concept of inheritance allows the customization of an existing class to meet particular needs. This can reduce the time and effort needed to design, implement, and maintain large systems

Functional Decomposition lA technique for developing a program in which the problem is divided into more easily handled subproblems, the solutions of which create a solution to the overall problem lIn functional decomposition, we work from the abstract (a list of the major solution steps for which some implementation details remain unspecified) to the concrete (algorithmic steps for which the implementation details are fully specified)

Functional Decomposition lFocus is on the sequence of actions (algorithms) required to solve the problem lBegins by breaking the solution into a series of major steps. This process continues until each subproblem cannot be divided further or has an obvious solution lPrograms are collections of modules that solve subproblems; a module structure chart (hierarchical solution tree) is often created lData plays a secondary role in support of actions

9 Definitions in Functional Decomposition l Concrete step A step for which the implementation details are fully specified l Abstract step A step for which some implementation details remain unspecified l Module A self-contained collection of steps that solves a problem or subprogram; it can contain both concrete and abstract steps

Find Weighted Average Print Weighted Average Module Structure Chart Main Print Data Print Heading Get Data Prepare File for Reading

11 Two Design Strategies FUNCTION OBJECT FUNCTIONAL OBJECT-ORIENTED DECOMPOSITION DESIGN

12 Object-Oriented Design Process l Three steps in the process nIdentify an initial set of object classes that seem relevant to the problem –nouns often represent objects –verbs often represent actions nFilter the list, eliminating duplicates nIdentify the responsibilities for the reduced list of objects

13 Identify Possible Classes l Brainstorming (by a team) nIdentify objects nPropose classes nWrite on a blackboard l Keep going around until no one can think of any more objects l No ideas are rejected

14 Filter List of Possible Classes l Eliminate duplicates l Decide if the classes really do represent objects in the problem l Look for classes that are related l Over looked classes may emerge l For each class that survives the filtering stage, create a CRC card

15 Blank CRC Card Class Name: Superclass: Subclasses: ResponsibilitiesCollaborations

16 Definitions l Responsibilities An action that an implementation of an object must be capable of performing l Collaboration An interaction between objects in which one object requests that another object carry out one of its responsibilities

17 Determine Responsibilities l Initial responsibilities nKnow and return the states of the object nCalled Knowledge Responsibilities l Action responsibilities Use scenario walk-throughs, a role playing technique, nto explore the actions of a class nto explore the interactions of classes

18 Address CRC Card Class Name: Superclass: Subclasses: Address Responsibilities Collaborations Create itself None (name, city, state, zip code) Know its name None Know its city None Know its state None Know its zip code None

19 Name CRC Card Class Name: Name Superclass: Subclasses: Responsibilities Collaborations Create itself (First, Middle, Last) None Know its first name None Know its middle name None Know its last name None Are two names equal? String Compare two namesString

20 Name CRC Card with Return Types Class Name: Name Superclass: Subclasses: Responsibilities Collaborations Create itself (First, Middle, Last) None Know its first name None return String Know its middle name None return String Know its last name None return String Are two names equal? String return boolean Compare two namesString return int

21 CRC Card Summary l The use of Classes, Responsibilities and Collaborations (CRC) cards is an informal technique for developing objected-oriented designs l For each class, a CRC card is created listing the class responsibilities and collaborations l Brainstorming, filtering, and scenarios are used to identify and refine the classes and responsibilities needed to solve a problem

22 Inheritance l Inheritance A mechanism that enables us to define a new class by adapting the definition of an existing class l Example on next slide l Detailed explanation in next Chapter

23 Address object inheritance hierarchy Object CompanyAddressHomeAddress BoxAddressWorkAddress Address

24 Categories of Responsibilities l Constructor An operation that creates a new instance of a class l Copy constructor An operation that creates a new instance by copying an existing instance, possibly altering its state in the process l Transformer An operation that changes the state of an object l Observer An operation that allows us to observe the state of an object without changing it l Iterator An operation that allows us to process all the components of an object one at a time

Methods are written to specifications (as on CRC card) l The specifications state the result type, the parameter types, and what task the method is to perform using its parameters l The advantage is that teamwork can occur without knowing what the argument identifiers will actually be

26 Instance Methods l CRC card responsibilities are implemented as methods in the class l A responsibility that refers to an object should be implemented as an instance method l Constructors, observers, transformers, and iterators are instance methods; they have access to the fields of their associated object, and can receive values through the parameter list

27 Three Categories of Data l Instance data is the internal representation of a specific object. It records the object’s state. l Class data is accessible to all objects of a class. l Local data is specific to a given call of a method.

Instance Data Instance data is the internal representation of a specific object. public class Name { // Instance variables String first; String middle; String last;... }

Class Data l Class data is accessible to all objects of a class. l Fields declared as static belong to the class rather than to a specific instance. public class Name { // Class constant static final String PUNCT = “, ”;... }

Local Data l Local data is specific to a given call of a method. l The JVM allocates space for this data when the method is called and deallocates it when the method returns. public int compareTo(Name otherName) { int result; // Local variable... return result; }

31 Package Syntax Compilation Unit package Identifier ; ImportDeclaration... ClassDeclaration...

32 Package Do’s and Don’t’s l A compilation unit can have only one public class l Many compilation units can be in a package l “No modifier” specifies package access l Any field or method with package access can be accessed by any member of the package

33 Package Example l package addressBook l Members: class Address nclass Entry l Imported by class AddressDr l All of the variables have package access

34 Ethics and Responsibilities l Software piracy The unauthorized copying of software for either personal use or use by others Have you every made unauthorized copies? Has anyone you know done so? Why is it wrong to do so?

35 More on Ethics l Virus Code that replicates itself, often with the goal of spreading to other computers without authorization, and possibly with the intent of doing harm Has a virus ever attached your machine? Why is creating and/or spreading a virus unethical?