Chapter 1: Programming Principles

Similar documents
Chapter 1: Principles of Programming and Software Engineering

Lecture Chapter 2 Software Development

Chapter 1: Key Concepts of Programming and Software Engineering

Introduction to Data Structures & Algorithm

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli

SRI VENKATESWARA COLLEGE OF ENGINERRING AND TECHNOLOGY THIRUPACHUR,THIRUVALLUR UNIT I OOAD PART A

Assertions. Assertions - Example

Object-Oriented Design

Software Engineering with Objects and Components Open Issues and Course Summary

Incremental development A.Y. 2018/2019

Overview of the lecture. Some key issues in programming Java programming. CMPT Data and Program Abstraction. Some of the key programming issues

17. Assertions. Outline. Built-in tests. Built-in tests 3/29/11. Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Object Oriented Programming

CSI33 Data Structures

References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1

Patterns and Testing

CS487 Midterm Exam Summer 2005

Introduction to Software Engineering

Data Structures and Algorithms for Engineers

17. Assertions. Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen

Review Software Engineering October, 7, Adrian Iftene

What s Next. INF 117 Project in Software Engineering. Lecture Notes -Spring Quarter, Michele Rousseau Set 6 System Architecture, UML

1. Introduction to Object Oriented Software Development

CS2353 OBJECT ORIENTED ANALYSIS AND DESIGN UNIT- I

CHAPTER 9 DESIGN ENGINEERING. Overview

Software Life Cycle. Main issues: Discussion of different life cycle models Maintenance or evolution

CSC Advanced Object Oriented Programming, Spring Overview

Managing Change and Complexity

Object Orientated Analysis and Design. Benjamin Kenwright

Appendix A - Glossary(of OO software term s)

Summary of the course lectures

Systems Analysis and Design in a Changing World, Fourth Edition

Model-based Transition from Requirements to High-level Software Design

Requirements and Design Overview

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING CS2353-OBJECT ORIENTED ANALYSIS AND DESIGN. Unit-I. Introduction to OOAD

Agile Model-Driven Development with UML 2.0 SCOTT W. AM BLER. Foreword by Randy Miller UNIFIED 1420 MODELING LANGUAGE. gile 1.

Examples. Object Orientated Analysis and Design. Benjamin Kenwright

Lethbridge/Laganière 2005 Chapter 9: Architecting and designing software 6

Outline of UML and Unified Process. Object Oriented Analysis/Design/Programming UML1.5. Koichiro Ochimizu, JAIST. UML&UP outline 1.

CHAPTER 5 GENERAL OOP CONCEPTS

What is an algorithm?

Goals of design. satisfies problem requirements, usable error free, resistant to incorrect input. readable, not purposefully cryptic.

Programmazione. Prof. Marco Bertini

Presenter: Dong hyun Park

10조 이호진 이지 호

340 Review Fall Midterm 1 Review

Software Architecture and Design I

Object-Oriented Design

OBJECT ORIENTED SYSTEM DEVELOPMENT Software Development Dynamic System Development Information system solution Steps in System Development Analysis

Software Process. Software Process

Chapter 8: Class and Method Design

Darshan Institute of Engineering & Technology for Diploma Studies Rajkot Unit-1

Week 9 Implementation

Principles of Software Construction: Objects, Design, and Concurrency

UNIT I. 3. Write a short notes on process view of 4+1 architecture. 4. Why is object-oriented approach superior to procedural approach?

Software Engineering

Introduction - SENG 330. Object-Oriented Analysis and Design

The Web Service Sample

Software Design and Implementation. Example Architecture KIWC

VEL TECH HIGH TECH Dr. RANGARAJAN Dr. SAKUNTHALA ENGINEERING COLLEGE UNIT 1 UML DIAGRAMS

UNIT 1-UMAL DIAGRAMS. Q.No. Question Competence Level. 1 What is Object Oriented analysis & Design? Remembering BTL1

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

In this Lecture you will Learn: Design Patterns. Patterns vs. Frameworks. Patterns vs. Frameworks

Classes, interfaces, & documentation. Review of basic building blocks

CASE TOOLS LAB VIVA QUESTION

UNIT-I Introduction of Object Oriented Modeling

Activities Common to Software Projects. Software Life Cycle. Activities Common to Software Projects. Activities Common to Software Projects

Software Processes. Ian Sommerville 2006 Software Engineering, 8th edition. Chapter 4 Slide 1

Object-Oriented Design

History of object-oriented approaches

Software Engineering Testing and Debugging Testing

Topic : Object Oriented Design Principles

UML Primer. -Elango Sundaram

Abstraction. Abstraction

Ans 1-j)True, these diagrams show a set of classes, interfaces and collaborations and their relationships.

Chapter 5 Object-Oriented Programming

Object-Oriented Analysis and Design Using UML

Object Model. Object Orientated Analysis and Design. Benjamin Kenwright

Principles of Software Construction: Objects, Design, and Concurrency

Safety SPL/2010 SPL/20 1

Unit Wise Questions. Unit-1 Concepts

Unit-3 Software Design (Lecture Notes)

Design Concepts and Principles

Chapter 9. Software Testing

Unit 6 - Software Design and Development LESSON 7 CODE STRUCTURES

INTRODUCTION TO UNIFIED MODELING MODEL (UML) & DFD. Slides by: Shree Jaswal

Object Oriented Analysis and Design - Part2(Design)

CTIS 359 Principles of Software Engineering SOFTWARE DESIGN OO(A)D

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

Design Concepts. Slide Set to accompany. Software Engineering: A Practitioner s Approach, 7/e by Roger S. Pressman

Object-Oriented Development and UML. Announcement. Agenda 7/3/2008. Class will resume on July 22. Try to complete the lab assignments by July.

Testing Object-Oriented Software. 22 November 2017

Fundamental Concepts (Principles) of Object Oriented Programming These slides are based on:

Object-Oriented Design

Software Development Methodologies

Objects First with Java

Introduction to Software Engineering. 5. Modeling Objects and Classes

SHRI ANGALAMMAN COLLEGE OF ENGINEERING & TECHNOLOGY (An ISO 9001:2008 Certified Institution) SIRUGANOOR,TRICHY

Part 7 - Object Oriented Concepts Classes, Objects, Properties and Methods

Transcription:

Chapter 1: Programming Principles Object Oriented Analysis and Design Abstraction and information hiding Object oriented programming principles Unified Modeling Language Software life-cycle models Key programming issues 1-1

Abstraction and Information Hiding Abstraction provide an easier higher-level interface to mask possibly complex low-level details functional abstraction separates the purpose of a module from its implementation specifications for each module are written before implementation data abstraction focuses on the operations of data, not on the implementation of the operations 1-2

Abstraction and Information Hiding Abstract data type (ADT) a collection of data and a set of operations on the data you can use an ADT s operations without knowing their implementations or how data is stored, if you know the operations specifications Data structure construct that is defined within a programming language to store a collection of data 1-3

Abstraction and Information Hiding Information hiding hide details within a module ensure that no other module can tamper with these hidden details public view of a module described by its specifications private view of a module implementation details that the specifications should not describe 1-4

Principles of Object-Oriented Object-oriented languages enable us to build classes of objects A class combines Programming (OOP) attributes of objects of a single type typically data called data members behaviors (operations) typically operate on the data called methods or member functions 1-5

Principles of Object-Oriented Three principles of OOP Encapsulation objects combine data and operations hides inner details Inheritance classes can inherit properties from other classes existing classes can be reused Polymorphism Programming (OOP) objects can determine appropriate operations at execution time 1-6

Object-Oriented Analysis & Design A team of programmers for a large software development project requires an overall plan organization communication Problem solving understanding the problem statement design a conceptual solution implement (code) the solution OOA/D is a process for problem solving. 1-7

Object-Oriented Analysis & Design Analysis Process to develop an understanding of the problem the requirements of a solution what a solution must be and do, and not how to design or implement it Object-oriented analysis (OOA) expresses an understanding of the problem and the requirements of a solution in terms of objects objects represent real-world objects, software systems, ideas OOA describes objects and their interactions among one another 1-8

Object-Oriented Analysis & Design Object-oriented design expresses an understanding of a solution that fulfills the requirements discovered during OOA describes a solution in terms of software objects, and object collaborations objects collaborate when they send messages creates one or more models of a solution some emphasize interactions among objects others emphasize relationships among objects 1-9

Applying the UML to OOA/D Unified Modeling Language (UML) tool for exploration and communication during the design of a solution models a problem domain in terms of objects independently of a programming language visually represents object-oriented solutions as diagrams enables members of a programming team to communicate visually with one another and gain a common understanding of the system being built 1-10

Applying the UML to OOA/D UML use case for OOA A set of textual scenarios (stories) of the solution each scenario describes the system s behavior under certain circumstances from the perspective of the user focus on the responsibilities of the system to meeting a user s goals main success scenario (happy path): interaction between user and system when all goes well alternate scenarios: interaction between user and system under exceptional circumstances Find noteworthy objects, attributes, and associations within the scenarios 1-11

Applying the UML to OOA/D An example of a main success scenario customer asks to withdraw money from a bank account bank identifies and authenticates customer bank gets account type, account number, and withdrawal amount from customer bank verifies that account balance is greater than withdrawal amount bank generates receipt for the transaction bank counts out the correct amount of money for customer customer leaves bank 1-12

Applying the UML to OOA/D An example of an alternate scenario customer asks to withdraw money from a bank account bank identifies, but fails to authenticate customer bank refuses to process the customer s request customer leaves bank 1-13

Applying the UML to OOA/D Figure 1-2 Sequence diagram for the main success scenario 1-14

Applying the UML to OOA/D Figure 1-3 Sequence diagram showing the creation of a new object 1-15

Applying the UML to OOA/D UML class (static) diagram Represents a conceptual model of a class of objects in a language-independent way Shows the name, attributes, and operations of a class Shows how multiple classes are related to one another 1-16

Applying the UML to OOA/D Figure 1-4 Three possible class diagrams for a class of banks 1-17

Applying the UML to OOA/D Figure 1-5 A UML class diagram of a banking system 1-18

Applying the UML to OOA/D Class relationships association classes know about each other (Bank Customer classes) aggregation (Containment) One class contains instance of another class (Bank Account classes) lifetime of the containing and contained may be the same (composition) generalization indicates a family of classes related by inheritance Checking and Savings inherit attributes and operations of Account 1-19

The Software Life Cycle Describes phases of s/w development from conception, deployment, replacement to deletion Iterative and Evolutionary Development many short, fixed-length iterations build on the previous iteration iteration cycles through analysis, design, implementation, testing, and integration of a small portion of the problem domain early iterations create the core of the system; further iterations build on that core 1-20

Software Life Cycle Rational Unified Process (RUP) Development RUP uses the OOA/D tools four development phases Inception: feasibility study, project vision, time/cost estimates Elaboration: refinement of project vision, time/cost estimates, and system requirements; development of core system Construction: iterative development of remaining system Transition: testing and deployment of the system 1-21

Rational Unified Process (RUP) Development Phases Figure 1-8 Relative amounts of work done in each development phase 1-22

Software Life Cycle Waterfall Method of Development develops a solution through sequential phases requirements analysis, design, implementation, testing, deployment hard to correctly specify a system without early feedback wrong analysis leads to wrong solution outdated (less used) do not impose this method on RUP development 1-23

Achieving a Better Solution Analysis and design improve solutions Cohesion perform one well-defined task for self-documenting, easy-to-understand code easy to reuse in other software projects easy to revise or correct Robust less likely to be affected by change; performs well under unusual conditions promotes low coupling 1-24

Achieving a Better Solution Coupling not dependent on other modules system of modules with low coupling is easier to change and understand module with low coupling is easier to reuse and has increased cohesion coupling is necessary for objects to collaborate should be minimized; well-defined class diagrams show dependencies among classes, and hence coupling 1-25

Achieving a Better Solution Minimal and complete interfaces class interface declares publicly accessible methods (and data) classes should be easy to understand, and so have few methods complete interface provide all methods consistent with the responsibilities of the class minimal interface provide only essential methods 1-26

Operation Contracts A module s operation contract specifies its purpose, assumptions, input, output Begin during analysis, finish during design used to document code Contract shows the responsibilities of one module to another Does not describe how the module will perform its task 1-27

Operation Contracts Specify data flow among modules what data is available to a module? what does the module assume? what actions take place? what effect does the module have on the data? Precondition statement of conditions that must exist before a module executes Postcondition statement of conditions that exist after a module executes 1-28

Operation Contracts First draft specifications -- sort(anarray, num) // Sorts an array. // Precondition: anarray is an array of num integers; num > 0. // Postcondition: The integers in anarray are sorted. Revised Specifications -- sort(anarray, num) // Sorts an array into ascending order. // Precondition: anarray is an array of num // integers; 1 <= num <= MAX_ARRAY, where // MAX_ARRAY is a global constant that specifies // the maximum size of anarray. // Postcondition: anarray[0] <= anarray[1] <=... // <= anarray[num-1], num is unchanged 1-29

Verification Assertion a statement about a particular condition at a certain point in an algorithm like, preconditions and postconditions Invariant a condition that is always true at a certain point in an algorithm Loop invariant a condition that is true before and after each loop iteration can be used to detect errors before coding is started 1-30

What is a Good Solution? A solution is good if: the total cost it incurs over all phases of its life cycle is minimal The cost of a solution includes: computer resources that the program consumes difficulties encountered by users consequences of a program that does not behave correctly Programs must be well structured and documented Efficiency is one aspect of a solution s cost 1-31

Key Issues in Programming Modularity Style Modifiability Ease of Use Fail-safe programming Debugging Testing 1-32

Key Issues in Programming: Modularity Modularity has a favorable impact on Constructing programs Debugging programs Reading programs Modifying programs Eliminating redundant code 1-33

Key Issues in Programming: Style Use of private data members Proper use of reference arguments Avoidance of global variables in modules Error handling Readability Documentation 1-34

Key Issues in Programming: Modifiability Modifiability is easier through the use of Named constants The typedef statement 1-35

Key Issues in Programming: Ease of Use In an interactive environment, the program should prompt the user for input in a clear manner A program should always echo its input The output should be well labeled and easy to read 1-36

Key Issues in Programming: Fail-Safe Programming Fail-safe programs will perform reasonably no matter how anyone uses it Test for invalid input data and program logic errors Check invariants Enforce preconditions Check argument values 1-37

Key Issues in Programming: Programmer must systematically check a program s logic to find where an error occurs Tools to use while debugging: single-stepping watches breakpoints print statements dump functions Debugging 1-38

Key Issues in Programming: Testing Levels of testing Unit testing: Test methods, then classes Integration testing: Test interactions among modules System testing: Test entire program Acceptance testing: Show system complies with requirements Types Open-box (white-box or glass-box) testing test knowing the implementation test all lines of code (decision branches, etc.) Closed-box (black-box or functional) testing test knowing only the specifications 1-39

Key Issues in Programming: Testing Developing test data include boundary values need to know expected results Techniques assert statements to check invariants disable, but do not remove, code used for testing /* and */ boolean checks pre-processor macros 1-40