CSE 403, Spring 2008, Alverson Software Design “There are two ways of constructing a software design: one way is to make it so simple that there are obviously.

Slides:



Advertisements
Similar presentations
Software Engineering Key design concepts Design heuristics Design practices.
Advertisements

Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use.
Patterns Reusable solutions to common object-oriented programming problems When given a programming problem, re-use an existing solution. Gang of Four.
05/26/2004www.indyjug.net1 Indy Java User’s Group June Knowledge Services, Inc.
(c) 2009 University of California, Irvine – André van der Hoek1June 13, 2015 – 21:42:16 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
Design Patterns CS is not simply about programming
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
Dept. of Computer Engineering, Amir-Kabir University 1 Design Patterns Dr. Noorhosseini Lecture 2.
(c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Design Patterns Introduction. What is a Design Pattern?  A technique to repeat designer success.  Borrowed from Civil and Electrical Engineering domains.
Design Patterns Alan Shalloway, James Trott, Design Patterns Explained, Addison-Wesley, Gamma, Helm, Johnson, Vlissides, Design Patterns, Elements.
Software Waterfall Life Cycle Requirements Construction Design Testing Delivery and Installation Operations and Maintenance Concept Exploration Prototype.
樣式導向設計 (Pattern-Oriented Design) 課程簡介 Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
CSSE 374: Introduction to Gang of Four Design Patterns
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
January 12, Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable.
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Design Patterns in Java Chapter 1 Introduction Summary prepared by Kirk Scott 1.
Powerpoint Templates Page 1 Powerpoint Templates What is Design Patterns ? by Indriati Teknik Informatika – UB.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
CSE 403 Lecture 14 Design Patterns. Today’s educational objective Understand the basics of design patterns Be able to distinguish them from design approaches.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
Testing Extensible Design Patterns in OO Frameworks through Scenario Templates D.S. Sanders Software Verification & Validation.
ECE450S – Software Engineering II
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
1 Design Patterns Object-Oriented Design. 2 Design Patterns 4Reuse of design knowledge and experience 4Common in many engineering disciplines 4Avoids.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Design Pattern Catalog - Page L3-1 PS95&96-MEF-L10-1 Dr. M.E. Fayad Creationa.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
Design Patterns Introduction
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
11 Jul 2005CSE403, Summer'05, Lecture 08 Lecture 08: Best Practices for Software Design (Part I) Valentin Razmov.
Design Patterns in Context ©SoftMoore ConsultingSlide 1.
07 Jul 2006CSE403, Summer'06, Lecture10 Lecture 10: Core Principles and Best Practices for Software Design (Part I) “Treat design as a wicked, sloppy,
7 April 2004CSci 210 Spring Design Patterns 2 CSci 210.
Basic Characteristics of Object-Oriented Systems
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
CSCI 3428: Software Engineering Tami Meredith Chapter 5 Design Patterns.
14 Jul 2005CSE403, Summer'05, Lecture 09 Lecture 09: Fundamental Principles and Best Practices for Software Design Valentin Razmov.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Design Patterns: MORE Examples
The Object-Oriented Thought Process Chapter 15
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
Software Design Patterns
MPCS – Advanced java Programming
Introduction to Design Patterns
Design Patterns Lecture part 2.
Introduction to Design Patterns
object oriented Principles of software design
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
Software Engineering Lecture 7 - Design Patterns
Informatics 122 Software Design II
Questions First On class? On project? On material we’ve discussed?
DESIGN PATTERNS : Introduction
Informatics 122 Software Design II
Chapter 8, Design Patterns Introduction
Presentation transcript:

CSE 403, Spring 2008, Alverson Software Design “There are two ways of constructing a software design: one way is to make it so simple that there are obviously no deficiencies; the other is to make it so complicated that there are no obvious deficiencies.” -- C.A.R. Hoare (1985)

CSE 403, Spring 2008, Alverson Readings “Code Complete (2 nd ed.)”, chapter 5, pg by Steve McConnell (link on Calendar) Summary is only on a portion of the chapter, but please read the whole chapter. It’s good!

CSE 403, Spring 2008, Alverson Where does design fit? Requirements Code Architecture – high level design Low level design

CSE 403, Spring 2008, Alverson Architecture is design Architecture, high level design, focuses on system components and their connections Low level design is a step closer to code. It looks at objects, classes, algorithms, variables, … The boundary between high and low level design is blurry. Many of the same principles apply!

CSE 403, Spring 2008, Alverson Good design quotes The driving force behind design is managing complexity The goal of all software design techniques is to break a complicated problem into simple pieces The key to performance is elegance, not battalions of special cases. Pragmatic Programmer

CSE 403, Spring 2008, Alverson What do we want in a design? Top 7 desirable characteristics: 1. Minimal complexity 2. Loose coupling 3. Strong cohesion 4. Extensibility 5. Reusability 6. Maintainability 7. Leanness 1. Code Complete

CSE 403, Spring 2008, Alverson Loose coupling coupling assesses the kind and quantity of interconnections among modules Modules that are loosely coupled (or uncoupled) are better than those that are tightly coupled The more tightly coupled are two modules, the harder it is to work with them separately, and thus the benefits become more limited

CSE 403, Spring 2008, Alverson Pragmatic Programmer agrees Eliminate Effects Between Unrelated Things – design components that are self-contained, independent, and have a single, well-defined purpose Pragmatic Programmer

CSE 403, Spring 2008, Alverson Tightly or loosely coupled?

CSE 403, Spring 2008, Alverson Tightly or loosely coupled?

CSE 403, Spring 2008, Alverson Tightly or loosely coupled?

CSE 403, Spring 2008, Alverson Strong cohesion cohesion refers to how closely the operations in a module are related Tight relationships improve clarity and understanding Classes with good abstraction usually have strong cohension No schizophrenic classes!

CSE 403, Spring 2008, Alverson Strong or weak cohesion? class Employee { public: … FullName GetName() const; Address GetAddress() const; PhoneNumber GetWorkPhone() const; … bool IsJobClassificationValid(JobClassification jobClass); bool IsZipCodeValid (Address address); bool IsPhoneNumberValid (PhoneNumber phoneNumber); … SqlQuery GetQueryToCreateNewEmployee() const; SqlQuery GetQueryToModifyEmployee() const; SqlQuery GetQueryToRetrieveEmployee() const; … }

CSE 403, Spring 2008, Alverson How do we attack the design process? Treat design as a wicked, sloppy, heuristic process. Don’t settle for the first design that occurs to you. Collaborate. Strive for simplicity. Prototype when you need to. Iterate, iterate, and iterate again. -- Steve McConnell, Code Complete

CSE 403, Spring 2008, Alverson Heuristics help provide ideas There is no “right answer” with design Applying effective heuristics can provide insights and lead to a good design Code Complete Chapter 5 looks at 9 heuristics: 1. Identify objects 2. Form consistent abstractions 3. Encapsulate implementation details 4. Favor composition over inheritance 5. Hide information 6. Keep coupling loose and cohesion strong 7. Identify areas likely to change * in your project 8. Use design patterns 9. Consider testability 10. Other common principles

CSE 403, Spring 2008, Alverson Inheritance inheritance promotes abstraction and reuse but breaks encapsulation The main guiding philosophy is that inheritance should be used only when a subclass is-a superclass. Kid Person

CSE 403, Spring 2008, Alverson Composition Compose by making a class an instance of another class (instead of a subclass) PickyEatingPattern Kid Class Kid { private: EatingPattern *ep; } Kid::Kid() { ep = new PickyEatingPattern; }

CSE 403, Spring 2008, Alverson Favor composition over inheritance KidEatingPattern Kid PickyEatingPatternKid Kid kid = new PickyEatingPatternKid; Kid::Kid() { ep = new PickyEatingPattern() }

CSE 403, Spring 2008, Alverson Composition Fosters reuse Keeps class libraries shallow (easier to understand) Keeps encapsulation strong Decouples concepts Enables runtime binding PickyEatingPattern Dog

CSE 403, Spring 2008, Alverson Design patterns A design pattern is a repeatable solution to a common software design problem o example: Iterator pattern Defines an interface that declares methods for sequentially accessing the objects in a collection. o Example: Factory pattern Defines an interface that declares methods for letting a class defer instantiation to its subclass

CSE 403, Spring 2008, Alverson Recent history of patterns In 1990 a group called the Gang of Four (Gamma, Helm, Johnson, Vlissides) compiled a catalog of design patterns 1995 book Design Patterns: Elements of Reusable Object-Oriented Software is a classic of the field

CSE 403, Spring 2008, Alverson More about patterns A pattern describes a recurring software structure: o is abstract from concrete design elements o identifies classes, their collaborations and responsibilities o lists implementation trade-offs o are not code or designs; are “templates” to be instantiated The software engineer is required to: o evaluate trade-offs of using a pattern o make design and implementation decision how best to apply the pattern, perhaps modify it slightly o implement the pattern in code

CSE 403, Spring 2008, Alverson Can you think of benefits? Benefits of using patterns (from Sp08): o common vocabulary o allows new developers to come up to speed faster o use the results of experience in the field o provides a starting point for coding o capture good design principles, allowing extensibility, and all that good stuff

Great website on patterns CSE 403, Spring 2008, Alverson complete with code samples complete with code samples

CSE 403, Spring 2008, Alverson Gang of Four (GoF) patterns Creational Patterns (abstract object instantiation) Abstract Factory, Factory, Builder, Prototype Singleton Structural Patterns (combine objects) Adapter, Bridge, Composite, Decorator, Façade, Flyweight, Proxy Behavioral Patterns (communication btwn objects) Chain of responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor

403 Mid-Quarter Assessment Lead by Jim Borgford-Parnell, Ph.D. Assistant Director Center for Engineering Learning and Teaching CSE 403, Spring 2008, Alverson

Sp07 Final From a design perspective, would it be appropriate to implement a class House via inheritance from class Building in order to reuse the implementation of the many useful methods already defined in Building even if Building has other methods that have no meaning in the context of House? CSE 403, Spring 2008, Alverson