38
Introduction to Software Design Introduction to Software Design Chapter 1 Chapter 1

Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Introduction to Software DesignIntroduction to Software Design

Chapter 1Chapter 1

Page 2: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Chapter ObjectivesChapter Objectives

To become familiar with the software challenge and the software life cycleTo understand what activities take place in each phase of the software life cycleTo learn how to use top-down design and object-oriented designTo learn to use data abstraction, procedural abstraction, and information hiding to manage complexityTo learn how to draw class diagrams to document the interaction between classes

To become familiar with the software challenge and the software life cycleTo understand what activities take place in each phase of the software life cycleTo learn how to use top-down design and object-oriented designTo learn to use data abstraction, procedural abstraction, and information hiding to manage complexityTo learn how to draw class diagrams to document the interaction between classes

Page 3: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Chapter Objectives (continued)Chapter Objectives (continued)

To learn the role of abstract data types in building models of computer systems and how to implement them using classes and interfacesTo become familiar with use cases as a tool to document a system’s interaction with the userTo understand the software design process by following the design and implementation of an array-based telephone directoryTo become familiar with sequence diagrams as a tool for documenting the interaction between multiple classes used in a program

To learn the role of abstract data types in building models of computer systems and how to implement them using classes and interfacesTo become familiar with use cases as a tool to document a system’s interaction with the userTo understand the software design process by following the design and implementation of an array-based telephone directoryTo become familiar with sequence diagrams as a tool for documenting the interaction between multiple classes used in a program

Page 4: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

The Software ChallengeThe Software Challenge

In industry, a software product is expected to be used for an extended period of time by someone who did not write the program and who is not intimately familiar with its internal designInitial specification for a software product may be incompleteSpecification is clarified through extensive interaction between users of the software and the system analystA requirements specification should be generated at the beginning of any software projectDesigners and users should both approve the document

In industry, a software product is expected to be used for an extended period of time by someone who did not write the program and who is not intimately familiar with its internal designInitial specification for a software product may be incompleteSpecification is clarified through extensive interaction between users of the software and the system analystA requirements specification should be generated at the beginning of any software projectDesigners and users should both approve the document

Page 5: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

The Pizza Class ExerciseThe Pizza Class Exercise

Take out a sheet of paper and write your three most important requirements for a pizza.Take out a sheet of paper and write your three most important requirements for a pizza.

Page 6: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Class ResponseClass Response

Page 7: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Class ResponseClass Response

Page 8: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

The Software Life CycleThe Software Life Cycle

Software products go through several stages as they mature from initial concept to finished productThe sequence of stages is called a life cycleIt is important to design and document software in an organized way so that it can be easily understood and maintained after the initial releaseThe person who maintains the software is not necessarily the person who writes it

Software products go through several stages as they mature from initial concept to finished productThe sequence of stages is called a life cycleIt is important to design and document software in an organized way so that it can be easily understood and maintained after the initial releaseThe person who maintains the software is not necessarily the person who writes it

Page 9: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Software Life Cycle ModelsSoftware Life Cycle Models

Waterfall model: simplest way of organizing activities that transforms software from one stage to anotherActivities are performed in sequence and the results of one flows into the nextWaterfall model is simple but unworkable

Fundamental flaw is assumption that each stage can and must be completed before the next one occurs

Sometimes, it is not until the product is finished that the user can fully express his or her requirements

Waterfall model: simplest way of organizing activities that transforms software from one stage to anotherActivities are performed in sequence and the results of one flows into the nextWaterfall model is simple but unworkable

Fundamental flaw is assumption that each stage can and must be completed before the next one occurs

Sometimes, it is not until the product is finished that the user can fully express his or her requirements

Page 10: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Waterfall ModelWaterfall Model

Page 11: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Waterfall Model (continued)Waterfall Model (continued)

Page 12: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Software Life Cycle Models (continued)

Software Life Cycle Models (continued)

Common themes among alternative models is to develop software product in stages or cyclesUnified Model: the cycles are called phases and iterations and the activities are called workflowsFour phases

InceptionElaborationConstructionTransition

Common themes among alternative models is to develop software product in stages or cyclesUnified Model: the cycles are called phases and iterations and the activities are called workflowsFour phases

InceptionElaborationConstructionTransition

Page 13: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Software Life Cycle Models (continued)

Software Life Cycle Models (continued)

Page 14: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Software Life Cycle Activities (continued)

Software Life Cycle Activities (continued)

Certain activities are essential for software development

Requirements specificationArchitectural, component, and detailed designsImplementationUnit, integration, and acceptance testsInstallation and maintenance

Certain activities are essential for software development

Requirements specificationArchitectural, component, and detailed designsImplementationUnit, integration, and acceptance testsInstallation and maintenance

Page 15: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Software Life Cycle ActivitiesSoftware Life Cycle Activities

Page 16: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Software Life Cycle Activities (continued)

Software Life Cycle Activities (continued)

Requirements SpecificationSystem analyst works with software users to clarify the detailed system requirementsQuestions include format of input data, desired form of any output screens, and data validation

AnalysisMake sure you completely understand the problem before starting the design or program a solutionEvaluate different approaches to the design

Requirements SpecificationSystem analyst works with software users to clarify the detailed system requirementsQuestions include format of input data, desired form of any output screens, and data validation

AnalysisMake sure you completely understand the problem before starting the design or program a solutionEvaluate different approaches to the design

Page 17: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Software Life Cycle Activities (continued)

Software Life Cycle Activities (continued)

DesignTop-down approach: breaking a system into a set of smaller subsystemsObject-oriented approach: identification of a set of objects and specification of their interactionsUML diagrams are a design tool to illustrate the interactions between

ClassesClasses and external entities

DesignTop-down approach: breaking a system into a set of smaller subsystemsObject-oriented approach: identification of a set of objects and specification of their interactionsUML diagrams are a design tool to illustrate the interactions between

ClassesClasses and external entities

Page 18: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Software Life Cycle Activities (continued)

Software Life Cycle Activities (continued)

Page 19: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Software Life Cycle Activities (continued)

Software Life Cycle Activities (continued)

Page 20: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Using Abstraction to Manage Complexity

Using Abstraction to Manage Complexity

An abstraction is a model of a physical entity or activityAbstraction helps programmers deal with complex issues in a piecemeal fashionProcedural abstraction: distinguish what is to be achieved by a procedure from its implementationData abstraction: specify the data objects for a problem and the operations to be performed on them without concern for their representation in memory

An abstraction is a model of a physical entity or activityAbstraction helps programmers deal with complex issues in a piecemeal fashionProcedural abstraction: distinguish what is to be achieved by a procedure from its implementationData abstraction: specify the data objects for a problem and the operations to be performed on them without concern for their representation in memory

Page 21: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Using Abstraction to Manage Complexity (continued)

Using Abstraction to Manage Complexity (continued)

If a higher-level class references a data object only through its methods, the higher-level class will not have to be rewritten, even if the data representation changesInformation hiding: Concealing the details of a class implementation from users of the class

If a higher-level class references a data object only through its methods, the higher-level class will not have to be rewritten, even if the data representation changesInformation hiding: Concealing the details of a class implementation from users of the class

Page 22: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Abstract Data Types, Interfaces, and Pre- and Postconditions

Abstract Data Types, Interfaces, and Pre- and Postconditions

A major goal of software engineering is to write reusable codeAbstract data type (ADT): The combination of data together with its methodsA Java interface is a way to specify an ADT

The interface specifies the names, parameters, and return values of the ADT methods without specifying how the methods perform their operations and without specifying how the data is internally represented

Each class that implements an interface must provide the definitions of all methods declared in the interface

A major goal of software engineering is to write reusable codeAbstract data type (ADT): The combination of data together with its methodsA Java interface is a way to specify an ADT

The interface specifies the names, parameters, and return values of the ADT methods without specifying how the methods perform their operations and without specifying how the data is internally represented

Each class that implements an interface must provide the definitions of all methods declared in the interface

Page 23: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Abstract Data Types, Interfaces, and Pre- and Postconditions

(continued)

Abstract Data Types, Interfaces, and Pre- and Postconditions

(continued)

Page 24: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Abstract Data Types, Interfaces, and Pre- and Postconditions

(continued)

Abstract Data Types, Interfaces, and Pre- and Postconditions

(continued)You cannot instantiate an interfaceYou can declare a variable that has an interface type and use it to reference an actual objectA Java interface is a contract between the interface designer and the programmer who codes a class that implements the interfacePrecondition: a statement of any assumptions or constraints on the method data before the method begins executionPostcondition: a statement that describes the result of executing a method

You cannot instantiate an interfaceYou can declare a variable that has an interface type and use it to reference an actual objectA Java interface is a contract between the interface designer and the programmer who codes a class that implements the interfacePrecondition: a statement of any assumptions or constraints on the method data before the method begins executionPostcondition: a statement that describes the result of executing a method

Page 25: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Requirements Analysis, Use Cases, and Sequence Diagrams

Requirements Analysis, Use Cases, and Sequence Diagrams

First step in analysis is to study the problem of input and output requirements carefully to make sure they are understood and make senseUse case: list of the user actions and system responses for a particular sub-problem in the order that they are likely to occurSequence diagram: shows all the objects involved in this use case across the horizontal axis, time is shown along the vertical axis

First step in analysis is to study the problem of input and output requirements carefully to make sure they are understood and make senseUse case: list of the user actions and system responses for a particular sub-problem in the order that they are likely to occurSequence diagram: shows all the objects involved in this use case across the horizontal axis, time is shown along the vertical axis

Page 26: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Design of an Array-Based Phone Directory

Design of an Array-Based Phone Directory

Case study deals with design, implementation, and testing of the software-based phone directoryIn UML class diagrams

+ sign next to a method or attribute means it is public- sign next to a method or attribute means it is private

Classes to design include:PDUserInterfacePDApplicationPhoneDirectoryArrayBasedPDDirectoryEntry

Case study deals with design, implementation, and testing of the software-based phone directoryIn UML class diagrams

+ sign next to a method or attribute means it is public- sign next to a method or attribute means it is private

Classes to design include:PDUserInterfacePDApplicationPhoneDirectoryArrayBasedPDDirectoryEntry

Page 27: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Design of an Array-Based Phone Directory (continued)

Design of an Array-Based Phone Directory (continued)

Page 28: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Design of an Array-Based Phone Directory (continued)

Design of an Array-Based Phone Directory (continued)

Page 29: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Design of an Array-Based Phone Directory (continued)

Design of an Array-Based Phone Directory (continued)

Page 30: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Design of an Array-Based Phone Directory (continued)

Design of an Array-Based Phone Directory (continued)

Page 31: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Design of an Array-Based Phone Directory (continued)

Design of an Array-Based Phone Directory (continued)

Page 32: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Implementing and Testing the Array-Based Phone DirectoryImplementing and Testing the Array-Based Phone Directory

Page 33: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Implementing and Testing the Array-Based Phone Directory

(continued)

Implementing and Testing the Array-Based Phone Directory

(continued)Note that some code in this application is controversial

Combination of assignment with the evaluation of a conditionBreak statement allows exiting of the while loop without storing an entry

Note that some code in this application is controversialCombination of assignment with the evaluation of a conditionBreak statement allows exiting of the while loop without storing an entry

Page 34: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Implementing PDUserInterfaceImplementing PDUserInterface

PDUserInterface must contain a public method, processCommandsWe show two different classes that implement the PDUserInterface:

PDGUI ClassPDConsoleUI

PDUserInterface must contain a public method, processCommandsWe show two different classes that implement the PDUserInterface:

PDGUI ClassPDConsoleUI

Page 35: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Implementing PDUserInterface as GUI

Implementing PDUserInterface as GUI

This class provides a GUI input using JOptionPane dialog windowsThis class provides a GUI input using JOptionPane dialog windows

Page 36: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Implementing PDUserInterface as a console

Implementing PDUserInterface as a console

Implemented using PDConsoleUI classThis class uses System.out to display the menu of choices and results. It also uses a Scanner object (scIn) associated with System.in to read data from the keyboard.

Implemented using PDConsoleUI classThis class uses System.out to display the menu of choices and results. It also uses a Scanner object (scIn) associated with System.in to read data from the keyboard.

Page 37: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Chapter ReviewChapter Review

We introduced two software life cycle models (waterfall and Unified) and discussed the activities performed in each stage of these modelsProcedural abstraction, data abstraction, and information hiding are tools for managing program complexityA Java interface can specify an abstract data type (ADT) and a Java class can implement an ADTUse cases summarize the interaction between the user and the system during requirements specification and analysis

We introduced two software life cycle models (waterfall and Unified) and discussed the activities performed in each stage of these modelsProcedural abstraction, data abstraction, and information hiding are tools for managing program complexityA Java interface can specify an abstract data type (ADT) and a Java class can implement an ADTUse cases summarize the interaction between the user and the system during requirements specification and analysis

Page 38: Introduction to Software Design - cs.montana.edu · Introduction to Software Design Chapter 1Chapter 1. Chapter Objectives To become familiar with the software challenge and the software

Chapter Review (continued)Chapter Review (continued)

UML class diagrams are used during the analysis and design phases to document the interaction of classes with each other and with the userSequence diagrams and pseudocode can be used to describe the sequence of actions performed by a program that is implemented as a collection of multiple interacting classesSequence diagrams are employed during the design phase of the software life cycle

UML class diagrams are used during the analysis and design phases to document the interaction of classes with each other and with the userSequence diagrams and pseudocode can be used to describe the sequence of actions performed by a program that is implemented as a collection of multiple interacting classesSequence diagrams are employed during the design phase of the software life cycle