1. Where to start SE2811 Software Component Design Dr. Josiah Yoder

Slides:



Advertisements
Similar presentations
Differentiating with Questioning
Advertisements

ANU COMP2110 Software Design in 2003 Lecture 16Slide 1 Lecture 16: Introduction to design patterns 1What are they? 2Where do they come from? 3Why study.
SE2811 Week 7, Class 2 The Gang of Four and more … Lab Thursday: Quiz SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder.
Fundamentals of Software Development 1Slide 1 Gang of Four The beginnings… The original “patterns” idea was from architecture – there are repeatable patterns.
Objectives You should be able to describe:
13-Jul-15 Refactoring II. Books Design Patterns is the classic book by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides Basically a catalog.
Chapter 7 GRASP patterns Dr Seham Mostefai CAP 252.
Chapter Five An Introduction to Design Patterns Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
ANU COMP2110 Software Design in 2004 Lecture 15Slide 1 COMP2110 in 2004 Software Design Lecture 15: Software design patterns (2) 1What are design patterns?
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
CS 325: Software Engineering February 12, 2015 Applying Responsibility-Assignment Patterns Design Patterns Situation-Specific Patterns Responsibility-Assignment.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
CS2852 Week 3, Class 2 Today Stacks Queues SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1.
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
Game Programming Patterns From the book by Robert Nystrom
Week 3, Day 3: Singleton Pattern Quiz Status Russia Opportunity Muddiest Points – Patterns SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick.
SE-2811 Software Component Design Week 1, Day 2 Making teams Warm-up exercise Design pattern defined SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick.
Systems Requirements SE 3821 Design? Algorithms CS 2852.
Week 9, Day 2 Object-oriented Design Acknowledgement: These slides by Dr. Hasker SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
CS2910 Week 8, Class 2 Today Return Quiz Look at Schedule TCP implementation! Week 8, Monday Quiz on SMTP May include some questions requiring you to interpret.
SE-2811 Software Component Design Week 1, Day 1 Design pattern defined Code that needs a design pattern… SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick.
Week 6, Class 3: Composite Swing composites File composites Computer composites SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
Slide design: Dr. Mark L. Hornick
Introduction To Design Patterns
Topic 2: binary Trees COMP2003J: Data Structures and Algorithms 2
Computers & Programming (CSE 102)
Slide design: Dr. Mark L. Hornick
SE-3910 Real-time Systems Week 10, Class 3 Loop jamming
Slide design: Dr. Mark L. Hornick
The Singleton Pattern SE-2811 Dr. Mark L. Hornick.
Design Patterns Introduction
Open Addressing: Quadratic Probing
Object-Oriented Programming
Slide design: Dr. Mark L. Hornick
Composite Pattern SE2811 Software Component Design
SE-2811 Software Component Design
10 His pleasure is not in the strength of the horse, nor his delight in the legs of the warrior; 11 the Lord delights in those who fear him, who put their.
Slide design: Dr. Mark L. Hornick
3. Object-oriented Design
Welcome to Fairfield High School GCSE Option Choices
SE-2811 Software Component Design
08/15/09 Design Patterns James Brucker.
Chapter 22 Object-Oriented Design
Week 7, Class 1: The Command Pattern (cont.)
SE-2811 Software Component Design
SE2811 Software Component Design Dr. Rob Hasker
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder
Foundations for making smart decisions
7. Decorator SE2811 Software Component Design
SE2811 Software Component Design Dr. Rob Hasker
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder
13. Composite Pattern SE2811 Software Component Design
SE-2811 Software Component Design
Slide design: Dr. Mark L. Hornick
Polling vs. Interrupts CS2852 4/21/2019
Computational Thinking
Slide design: Dr. Mark L. Hornick
11. MVC SE2811 Software Component Design
Week 8, Class 3: Model-View-Controller
CS-2852 Data Structures Week 1, Class 1 Data Structures Syllabus
Slide design: Dr. Mark L. Hornick
11. MVC SE2811 Software Component Design
Slide design: Dr. Mark L. Hornick
SE-1021 Software Engineering II
16. Visitors SE2811 Software Component Design
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder
SE2811 Software Component Design Dr. Rob Hasker
5. Strategy, Singleton Patterns
Slide design: Dr. Mark L. Hornick
Presentation transcript:

1. Where to start SE2811 Software Component Design Dr. Josiah Yoder (Throughout this course, many slides originally by Dr. Hasker, Dr. Hornick, and Dr. Urbain) Acknowledgement 1. Where to start

SE 2811: Software Component Design CS-1020 11/19/2018 SE 2811: Software Component Design Systems Requirements SE 3821 Design? Algorithms CS 2852 Opportunities for reuse Classic reuse models: requirements, algorithms SE3821: Fall of Junior year in 3.3 curriculum. You can reuse full sets of requirements; it’s only effective when the problems are very similar. For example, the basic requirements for car door locks are independent of whether you have a key fob or enter a pin on the door. (Ask students for features that are common.) Dr. Mark L. Hornick

SE 2811: Software Component Design CS-1020 11/19/2018 SE 2811: Software Component Design Systems Requirements SE 3821 Design: SE 2811 Algorithms CS 2852 Opportunities for reuse Classic reuse models: requirements, algorithms 2811: reusing designs Print Dr. Mark L. Hornick

Administrative Break Safety Review Review Syllabus

Personal Note "Enter through the narrow gate. For wide is the gate and broad is the road that leads to destruction, and many enter through it. But small is the gate and narrow the road that leads to life, and only a few find it." - Jesus

Personal Note He does not delight in the strength of the horse; CS2911 19 November 2018 Personal Note He does not delight in the strength of the horse; He takes no pleasure in the legs of a man. The LORD takes pleasure in those who fear Him, In those who hope in His mercy. - Psalm 147 https://www.blueletterbible.org/nkjv/psa/147/10/s_625011 Dr. Josiah Yoder

SE 2811: Software Component Design CS-1020 11/19/2018 SE 2811: Software Component Design Systems Requirements SE 3821 Design: SE 2811 Algorithms CS 2852 Opportunities for reuse Classic reuse models: requirements, algorithms 2811: reusing designs Print Dr. Mark L. Hornick

SE 2811: Software Component Design CS-1020 11/19/2018 SE 2811: Software Component Design Systems Requirements SE 3821 Design: SE 2811 Algorithms CS 2852 Opportunities for reuse Classic reuse models: requirements, algorithms 2811: reusing designs 1994: Gang of 4 Gamma, Helm, Johnson, Vlissides Print Dr. Mark L. Hornick

SE 2811: Software Component Design CS-1020 11/19/2018 SE 2811: Software Component Design Systems Requirements SE 3821 Design: SE 2811 Algorithms CS 2852 Opportunities for reuse Classic reuse models: requirements, algorithms 2811: reusing designs 1994: Gang of 4 Gamma, Helm, Johnson, Vlissides Print Design pattern: general, reusable solution to a commonly occurring problem in software design Dr. Mark L. Hornick

A real-life example How to get from Milwaukee to Chicago? Identify at least four methods What are common elements? What can differ? How do we compare them? Are these algorithms? Algorithm: sequence of steps to be followed to calculate a result

Example #2 Problem: Workplace, home traffic pattern: travel to frequently accessed objects If objects scattered, flow of life is awkward Items forgotten, misplaced

Example #2 Problem: Workplace, home traffic pattern: travel to frequently accessed objects If objects scattered, flow of life is awkward Items forgotten, misplaced Solution: Waist-high shelves around at least part of main rooms in which people live & work They should be long, 22-40 cm deep Shelves or cupboard underneath Interrupt shelf for seats, windows, doors

Example #2 Note features: Shelf color, material not important to the structure Not an algorithm/not blueprints Architectural design pattern Are there times when the pattern is a poor choice? Each pattern: Solves a recurring problem Tradeoffs: advantages, disadvantages to applying

Software example public class StereoController {     private Volume volume;     private Equalizer equalizer;     public StereoController(Volume volume, Equalizer equalizer) {         this.volume = volume;         this.equalizer = equalizer;     }                                 public changeVolume(int ticks) {         volume.adjust(ticks);     }     public changeChannel(int channel, int ticks) {         if ( equalizer != null )             equalizer.getChannel(channel).adjust(ticks); }

Software example Models core elements of stereo: volume control, equalizer public class StereoController {     private Volume volume;     private Equalizer equalizer;     public StereoController(Volume volume, Equalizer equalizer) {         this.volume = volume;         this.equalizer = equalizer;     }                                 public changeVolume(int ticks) {         volume.adjust(ticks);     }     public changeChannel(int channel, int ticks) {         if ( equalizer != null )             equalizer.getChannel(channel).adjust(ticks); }

Software example Models core elements of stereo: volume control, equalizer If statement: allows stereo without equalizer Problem: will need to check every use Violates an OO principle: don’t repeat yourself Why is repetition a problem? How can we remove it? public class StereoController {     private Volume volume;     private Equalizer equalizer;     public StereoController(Volume volume, Equalizer equalizer) {         this.volume = volume;         this.equalizer = equalizer;     }                                 public changeVolume(int ticks) {         volume.adjust(ticks);     }     public changeChannel(int channel, int ticks) {         if ( equalizer != null )             equalizer.getChannel(channel).adjust(ticks); }

Solution: create “do nothing” classes public class Equalizer { public final int MAX_CHANNEL = 6; private Level[] channels = new Level[MAX_CHANNEL]; public Equalizer() { } public Level getChannel(int i) { return channels[i];     } } public class NullEqualizerObject { private NullLevelObject nullLevel = new NullLevelObject(); return nullLevel; public class NullLevelObject { public adjust(int value) { } } NullEqualizerObject: returned channel does nothing on adjust

Removing the `if’ Stereo without equalizer: public class StereoController {     private Volume volume;     private Equalizer equalizer;     public StereoController(Volume volume, Equalizer equalizer) {         this.volume = volume;         this.equalizer = equalizer;     }                                 public changeVolume(int ticks) {         volume.adjust(ticks);     }     public changeChannel(int channel, int ticks) {         equalizer.getChannel(channel).adjust(ticks); } Removing the `if’ new StereoController(new Volume(), new NullEqualizerObject()); Stereo without equalizer:

Null Object Pattern Create a class that mirrors another Each operation “does nothing” Value returning operations: return something reasonable Use this class wherever might have a check for null Advantage: avoid lots of “if ( x != null )…” Disadvantage: more classes to write Clearly a bad idea in this case! Possibly useful for full Stereo Also: may delay raising an error: fail fast! A significant part of the course: identify problems and solve those problems using (design) patterns

SE-2811 Software Component Design CS-1020 11/19/2018 SE-2811 Software Component Design See syllabus at https://faculty-web.msoe.edu/hasker/se2811 Required: Optional: Print Dr. Mark L. Hornick

Review Design patterns: capturing frequent design solutions Reusing designs in addition to requirements, algorithms Null Object Pattern: avoiding if ( x == null )… through “do nothing” classes Next: Adapter Pattern