SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture # 17 Good Software Design SWE 316: Software Design and Architecture.

Slides:



Advertisements
Similar presentations
Lecture 6: Software Design (Part I)
Advertisements

Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Chapter 13 Review Questions
COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
Architecting and Designing Software
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
9.5 Software Architecture
Chapter 1 Principles of Programming and Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Object-Oriented Software Engineering Practical Software Development using UML and Java Architecting and Designing Software Chapter 9 in OOSE Textbook plus.
Software Issues Derived from Dr. Fawcett’s Slides Phil Pratt-Szeliga Fall 2009.
System Architecture: Desing alternatives and methodologies.
Architecting and Designing Software Chapter 9 in OOSE Textbook plus
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
CS 4310: Software Engineering
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 system design 1 what is systems design? preparation of the system’s specifications with.
The Design Discipline.
Design COP 3538 Summer © Lethbridge/Laganière 2001 Chapter 9: Architecting and designing software 2 The Process of Design Definition: – Design is.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 11 : Frameworks SWE 316: Software Design and Architecture  To understand.
An Introduction to Software Architecture
CSE 303 – Software Design and Architecture
9.4 Software Architecture
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 9: Architecting and Designing Software.
COMP 354 Software Engineering I Section BB Summer 2009 Dr Greg Butler
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
SOFTWARE DESIGN (SWD) Instructor: Dr. Hany H. Ammar
CSE 240 Lecture 12. Quote of the day “There is no reason for any individual to have a computer in his home.” Ken Olsen ( ), President, Digital Equipment,
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 9: Architecting and Designing Software.
SE: CHAPTER 7 Writing The Program
Component Technology. Challenges Facing the Software Industry Today’s applications are large & complex – time consuming to develop, difficult and costly.
Systems Analysis and Design in a Changing World, 3rd Edition
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Chapter 6 Architectural design Chapter 6 – Architectural Design Lecture 1 1.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
GRASP: Designing Objects with Responsibilities
Object-Oriented Software Engineering Practical Software Development using UML and Java Architecting and Designing Software Chapter 9 in OOSE Textbook plus.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
Object-Oriented Software Engineering Practical Software Development using UML and Java Architecting and Designing Software Chapter 9 in OOSE Textbook plus.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Dr D. Greer, Queens University Belfast )Chapter Six 1 Software Engineering Chapter Six Software Design Quality Learning Outcomes.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
Introduction to OOP CPS235: Introduction.
Week 6: Software Design HNDIT Software Engineering Software Design Learning Outcomes  Understand the activities involved in the Design process.
Design CS 470 – Software Engineering I Sheldon X. Liang, PH.D.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 9: Architecting and Designing Software.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
CSCE 240 – Intro to Software Engineering Lecture 3.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 9: Architecting and Designing Software.
Principles of Programming & Software Engineering
And Some UML Diagrams in between
CompSci 280 S Introduction to Software Development
Coupling and Cohesion 1.
Architecting and Designing Software
SOFTWARE DESIGN AND ARCHITECTURE
Software Quality Engineering
Chapter 2: System Structures
Architecting and Designing Software
Starting Design: Logical Architecture and UML Package Diagrams
Analysis models and design models
An Introduction to Software Architecture
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
Designing Software.
Architecting and Designing Software
Architecting and Designing Software
Presentation transcript:

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture # 17 Good Software Design SWE 316: Software Design and Architecture  Practical tips for creating good design  Introduce practical tips for creating good design The slides and the material of this chapter are adopted from: “Object-Oriented Software Engineering: Practical Software Development using UML and Java”, 2 nd Ed. By Timothy C. Lethbridge and Robert Laganière

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Topics: Principles leading to good design  DP 1: divide and conquer  DP 2: increase cohesion where possible  DP 3: reduce coupling where possible  DP 4: keep the level of abstraction as high as possible  DP 5: increase reusability where possible  DP 6: reuse existing designs and code where possible  DP 7: design for flexibility  DP 8: anticipate obsolescence  DP 9: design for portability  DP 10: design for testability  DP 11: design defensively Intro Principles (1-2)Principles (3-4)Principles (5-7)Principles (8-11)Design Decisions 2/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Principles leading to good design  Overall goals of good design:  Increasing profit by reducing cost and increasing revenue  Ensuring that we actually conform with the requirements  Accelerating development  Increasing qualities such as UsabilityEfficiency ReliabilityMaintainability Reusability Intro Principles (1-2)Principles (3-4)Principles (5-7)Principles (8-11)Design Decisions 3/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 1: divide and conquer  Trying to deal with something big all at once is normally much harder than dealing with a series of smaller things  Separate people can work on each part.  An individual software engineer can specialize.  Each individual component is smaller, and therefore easier to understand.  Parts can be replaced or changed without having to replace or extensively change other parts. Intro Principles (1-2) Principles (3-4)Principles (5-7)Principles (8-11)Design Decisions 4/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Ways of dividing a software system  A distributed system is divided up into clients and servers  A system is divided up into subsystems  A subsystem can be divided up into one or more packages  A package is divided up into classes  A class is divided up into methods Intro Principles (1-2) Principles (3-4)Principles (5-7)Principles (8-11)Design Decisions 5/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 2: increase cohesion where possible  A subsystem or module has high cohesion if it keeps together things that are related to each other, and keeps out other things  This makes the system as a whole easier to understand and change  Type of cohesion: -Functional-Layer -Communicational-Sequential -Procedural-Temporal -Utility Intro Principles (1-2) Principles (3-4)Principles (5-7)Principles (8-11)Design Decisions 6/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 2: increase cohesion where possible (2) Intro Principles (1-2) Principles (3-4)Principles (5-7)Principles (8-11)Design Decisions 7/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 2: increase cohesion where possible (3) Intro Principles (1-2) Principles (3-4)Principles (5-7)Principles (8-11)Design Decisions 8/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 2: increase cohesion where possible (4)  Mixing different types of cohesion Intro Principles (1-2) Principles (3-4)Principles (5-7)Principles (8-11)Design Decisions 9/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 3: Reduce coupling where possible  Coupling occurs when there are interdependencies between one module and another  When interdependencies exist, changes in one place will require changes somewhere else.  A network of interdependencies makes it hard to see at a glance how some component works.  Type of coupling: -Content -Common -Control -Stamp -Data -Routine Call -Type use -Inclusion/Import -External IntroPrinciples (1-2) Principles (3-4) Principles (5-7)Principles (8-11)Design Decisions 10/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 3: Reduce coupling where possible IntroPrinciples (1-2) Principles (3-4) Principles (5-7)Principles (8-11)Design Decisions 11/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 3: Reduce coupling where possible IntroPrinciples (1-2) Principles (3-4) Principles (5-7)Principles (8-11)Design Decisions 12/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 3: Reduce coupling where possible  Content Coupling  A module modifies data that is internal to another component  It should always be AVOIDED  e.g., modify public instance variable IntroPrinciples (1-2) Principles (3-4) Principles (5-7)Principles (8-11)Design Decisions 13/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 3: Reduce coupling where possible  Control Coupling  This occurs when one procedure calls another using a ‘flag’ or ‘command’ that explicitly controls what the second procedure does. IntroPrinciples (1-2) Principles (3-4) Principles (5-7)Principles (8-11)Design Decisions 14/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 3: Reduce coupling where possible  Stamp Coupling  This occurs whenever a class is declared as the type of a method argument.  Some stamp coupling is necessary  What’s wrong in this implementation? IntroPrinciples (1-2) Principles (3-4) Principles (5-7)Principles (8-11)Design Decisions 15/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 4: Abstraction as high as possible  Abstractions --- keeping things simple !  keep the level of abstraction as high as possible  Ensure that your designs allow you to hide or defer consideration of details, thus reducing complexity  A good abstraction is said to provide information hiding  Abstractions allow you to understand the essence of a subsystem without having to know unnecessary details IntroPrinciples (1-2) Principles (3-4) Principles (5-7)Principles (8-11)Design Decisions 16/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Abstraction and classes  Classes are data abstractions that contain procedural abstractions  Abstraction is increased by defining all variables as private.  The fewer public methods in a class, the better the abstraction  Superclasses and interfaces increase the level of abstraction  Attributes and associations are also data abstractions.  Methods are procedural abstractions  Better abstractions are achieved by giving methods fewer parameters IntroPrinciples (1-2) Principles (3-4) Principles (5-7)Principles (8-11)Design Decisions 17/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 5: Increase reusability where possible  Design for reuse ---- Design with reuse  Design the various aspects of your system so that they can be used again in other contexts  Generalize your design as much as possible  Follow the preceding three design principles  Increase cohesion  Reduce coupling  Increase abstraction  Simplify your design as much as possible IntroPrinciples (1-2)Principles (3-4) Principles (5-7) Principles (8-11)Design Decisions 18/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 5: Increase reusability where possible  How?  Generalize your design as much as possible  Save instances of Employee class in a binary file  Instead, consider saving any class to binary file  Another example, generalize sorting  Design your system with hooks  An aspect of the design deliberately added to allow other designers to add additional functionality  Extensible compiler example IntroPrinciples (1-2)Principles (3-4) Principles (5-7) Principles (8-11)Design Decisions 19/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 6: reuse existing designs and code  Design with reuse is complementary to design for reusability  Actively reusing designs or code allows you to take advantage of the investment you or others have made in reusable components IntroPrinciples (1-2)Principles (3-4) Principles (5-7) Principles (8-11)Design Decisions 20/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 7: design for flexibility (adaptability)  Actively anticipate changes that a design may have to undergo in the future, and prepare for them  Reduce coupling and increase cohesion  Create abstractions  Do not hard-code anything  E.g., constants should be in a configuration file  Leave all options open  Do not restrict the options of people who have to modify the system later  Use reusable code and make code reusable IntroPrinciples (1-2)Principles (3-4) Principles (5-7) Principles (8-11)Design Decisions 21/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 8: Anticipate Obsolescence  Plan for changes in the technology or environment so the software will continue to run or can be easily changed  Avoid using early releases of technology  Avoid using software libraries that are specific to particular environments  Avoid using undocumented features or little-used features of software libraries  Avoid using software or special hardware from companies that are less likely to provide long-term support  Use standard languages and technologies that are supported by multiple vendors IntroPrinciples (1-2)Principles (3-4)Principles (5-7) Principles (8-11) Design Decisions 22/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 9: design for portability  Have the software run on as many platforms as possible  Avoid the use of facilities that are specific to one particular environment  E.g. a library only available in Microsoft Windows  Some programming languages, such as Java, make this easy because the language itself is designed to allow software to run on different platforms unchanged.  Another important portability issue has to do with text files: the characters used to terminate lines differ from platform to platform. IntroPrinciples (1-2)Principles (3-4)Principles (5-7) Principles (8-11) Design Decisions 23/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 10: Design for Testability  Take steps to make testing easier  Design a program to automatically test the software  Ensure that all the functionality of the code can by driven by an external program, bypassing a graphical user interface  In Java, you can create a main() method in each class in order to exercise the other methods IntroPrinciples (1-2)Principles (3-4)Principles (5-7) Principles (8-11) Design Decisions 24/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 11: Design defensively  Never trust how others will try to use a component you are designing  Handle all cases where other code might attempt to use your component inappropriately  Check that all of the inputs to your component are valid: the preconditions  Example: method to check if a certain date is working day IntroPrinciples (1-2)Principles (3-4)Principles (5-7) Principles (8-11) Design Decisions 25/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 11: Design defensively  What’s wrong with this implementation?  Design by Contract  Each method has a specific contract with its caller IntroPrinciples (1-2)Principles (3-4)Principles (5-7) Principles (8-11) Design Decisions 26/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser DP 11: Design defensively  Using Asserting  identify possible logic errors during development. IntroPrinciples (1-2)Principles (3-4)Principles (5-7) Principles (8-11) Design Decisions 27/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Techniques for making good design decisions  Using priorities and objectives to decide among alternatives  Step 1: List and describe the alternatives for the design decision.  Step 2: List the advantages and disadvantages of each alternative with respect to your objectives and priorities.  Step 3: Determine whether any of the alternatives prevents you from meeting one or more of the objectives.  Step 4: Choose the alternative that helps you to best meet your objectives.  Step 5: Adjust priorities for subsequent decision making. IntroPrinciples (1-2)Principles (3-4)Principles (5-7)Principles (8-11) Design Decisions 28/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Example priorities and objectives  Imagine a system has the following objectives, starting with top priority:  Security: Encryption must not be breakable within 100 hours of computing time on a 400Mhz Intel processor, using known cryptanalysis techniques.  Maintainability. No specific objective.  CPU efficiency. Must respond to the user within one second when running on a 400MHz Intel processor.  Network bandwidth efficiency: Must not require transmission of more than 8KB of data per transaction.  Memory efficiency. Must not consume over 20MB of RAM.  Portability. Must be able to run on Windows 98, NT 4 and ME as well as Linux IntroPrinciples (1-2)Principles (3-4)Principles (5-7)Principles (8-11) Design Decisions 29/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Example evaluation of alternatives IntroPrinciples (1-2)Principles (3-4)Principles (5-7)Principles (8-11) Design Decisions 30/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Example evaluation of alternatives IntroPrinciples (1-2)Principles (3-4)Principles (5-7)Principles (8-11) Design Decisions 31/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Cost-benefit analysis to choose among alternatives  To estimate the costs, add up:  The incremental cost of doing the software engineering work, including ongoing maintenance  The incremental costs of any development technology required  The incremental costs that end-users and product support personnel will experience  To estimate the benefits, add up:  The incremental software engineering time saved  The incremental benefits measured in terms of either increased sales or else financial benefit to users IntroPrinciples (1-2)Principles (3-4)Principles (5-7)Principles (8-11) Design Decisions 32/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Some general principles of good design  Use good design patterns, patterns of call-return or cooperative objects, event-structure should be consistent  Modular – logically partitioned into elements that perform specific functions and sub-functions.  Should have distinct representations of data, interfaces and components  Functions and components should be independent  Interfaces between components should be kept as simple as possible.  Use a repeatable method that transforms the requirements through analysis to high-level and then low-level design  Don’t reinvent the wheel. IntroPrinciples (1-2)Principles (3-4)Principles (5-7)Principles (8-11) Design Decisions 33/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser CRC cards  CRC stands for Classes, Responsibilities, Collaborations.  CRC cards allow people to break away from the procedural mode of thought and more fully appreciate object technology.  One common way of checking for a good design and guiding its refinement is to use CRC cards.  Although CRC is not part of UML, they add some very useful insights throughout a development. IntroPrinciples (1-2)Principles (3-4)Principles (5-7)Principles (8-11) Design Decisions 34/35

SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Summary  Overall goals of good design:  Increasing profit by reducing cost and increasing revenue  Ensuring that we actually conform with the requirements  Accelerating development  Increasing qualities such as  Design principles leading to good design:  Divide and conquer  Increase cohesion where possible  Reduce coupling where possible  Keep the level of abstraction as high as possible  Increase reusability where possible  Reuse existing designs and code where possible  Design for flexibility  Anticipate obsolescence  Design for portability  Design for testability  Design defensively IntroPrinciples (1-2)Principles (3-4)Principles (5-7)Principles (8-11)Design Decisions 35/35