K. Stirewalt CSE 335: Software Design Outline of course topics Foundational OO concepts Synthetic concepts: –Program families, program fragments, and abstract.

Slides:



Advertisements
Similar presentations
K. Stirewalt CSE 335: Software Design Synthetic OOD concepts and reuse Lecture 4: Separation of concerns Topics: –Complex concern: Memory management –
Advertisements

Observer Method 1. References Gamma Erich, Helm Richard, “Design Patterns: Elements of Reusable Object- Oriented Software” 2.
Introduction To System Analysis and Design
Object-Oriented Programming with Java The Java Event Model Lecture 5.
1 Software Testing and Quality Assurance Lecture 26 (a) – Testing Interactions (Chapter 6)
Object Oriented System Development with VB .NET
What is an object? Your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior;
Software Testing and Quality Assurance
R R R CSE870: Advanced Software Engineering: Frameworks (Cheng, Sp2003)1 Frameworks A Brief Introduction.
K. Stirewalt CSE 335: Software Design Synthetic OO Design Concepts & Reuse Lecture 2: Abstract classes and composite structures Topics: –Elaboration of.
Chair of Software Engineering 1 Introduction to Programming Tuples and Agents Exercise Session 1 and 2 December 2008.
K. Stirewalt CSE 335: Software Design Synthetic OO Design Concepts & Reuse Lecture 7: Roles and Collaborations Topics: – Interactive applications, their.
E. Kraemer CSE 335: Software Design Administrivia Exam 2 : Wednesday, March pm Room: TBA Wed, March 12th - exam outline in class Mon, March 17th.
Object-oriented Programming Concepts
Software Engineering I Object-Oriented Design Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science.
K. Stirewalt CSE 335: Software Design Synthetic OO Design Concepts & Reuse Lecture 9: Collaboration synthesis Topics: –Composition of existing collaborations.
Design Patterns Based on Design Patterns. Elements of Reusable Object-Oriented Software. by E.Gamma, R. Helm, R. Johnson,J. Vlissides.
K. Stirewalt CSE 335: Software Design Software Architecture and Larger System Design Issues Lecture 3: Synchronization Topics: –Concurrent access to shared.
Object-Oriented Analysis and Design
K. Stirewalt CSE 335: Software Design Software architecture and larger system design issues Lecture 1: Simulating concurrency Topics: –High-level software.
K. Stirewalt CSE 335: Software Design Synthetic OO Design Concepts & Reuse Lecture 5: Mixins and reusable strategies Topics: – More on the use of mixins.
K. Stirewalt CSE 335: Software Design Software Architecture and Larger System Design Issues Lecture 4: Life cycles of concurrent actors Topics: –The “life.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
Introduction To System Analysis and design
Programming With Java ICS201 University Of Hail1 Chapter 12 UML and Patterns.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
Object Oriented Software Development
Programming Languages and Paradigms Object-Oriented Programming.
Design Patterns.
Microsoft Visual Basic 2005: Reloaded Second Edition
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
An Object-Oriented Approach to Programming Logic and Design
Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Pattern Oriented Software Architecture for Networked Objects Based on the book By Douglas Schmidt Michael Stal Hans Roehnert Frank Buschmann.
Introduction To System Analysis and Design
ISP666 MVC & Design Patterns. Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise.
SIMPLE PROBLEM SOLVING in Java: a Problem Set Framework Viera K. Proulx Richard Rasala Jason Jay Rodrigues CCSCNE 2002 Conference.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
SNPL1 Woochang Lim What (Variable) + How (Function) = Object Objects are the physical and conceptual things we find in the universe around us. Object-Oriented.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Chapter 8 Object Design Reuse and Patterns. Object Design Object design is the process of adding details to the requirements analysis and making implementation.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many others 1.
An Introduction to Programming and Object Oriented Design using Java 3 rd Edition. Dec 2007 Jaime Niño Frederick Hosch Chapter 18 Integrating user interface.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Module 8: more on methods #1 2000/01Scientific Computing in OOCourse code 3C59 Module 8: More on methods: In this module we will cover: Overloading of.
Dale Roberts Object Oriented Programming using Java - Introduction Dale Roberts, Lecturer Computer Science, IUPUI Department.
Model View Controller MVC Web Software Architecture.
K. Stirewalt CSE 335: Software Design Synthetic OO Design Concepts & Reuse Lecture 8: Modeling & documenting collaborations Topics: –Synthesis of multiple.
Introduction to Java Programming
Abstraction ADTs, Information Hiding and Encapsulation.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many of others 1.
Design Reuse Earlier we have covered the re-usable Architectural Styles as design patterns for High-Level Design. At mid-level and low-level, design patterns.
Foundations: Language mechanisms and primitive OO concepts Lecture 1: Classification and Inheritance Michigan State University Spring 2008 E. Kraemer Notes.
K. Stirewalt CSE 335: Software Design Synthetic OO Design Concepts & Reuse Lecture 5: Mixins and reusable strategies Topics: – More on the use of mixins.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Design and implementation Chapter 7 – Lecture 1. Design and implementation Software design and implementation is the stage in the software engineering.
UQC117S2 Graphics Programming Lecture 2 Event Handling Program as a sequence of instructions Event -driven program Need to detect the event and carry out.
1 M206 Chapter 31: An Overview of Software Development 1.Defining the problem 2.Analyzing the requirement – constructing initial structural model 3.Analyzing.
Behavioral Design Patterns
Instructor: Dr. Hany H. Ammar
Ellen Walker Hiram College
EE 422C Java FX.
Constructors, GUI’s(Using Swing) and ActionListner
Adapter Pattern Jim Fawcett
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Adapter Pattern Jim Fawcett
Presentation transcript:

K. Stirewalt CSE 335: Software Design Outline of course topics Foundational OO concepts Synthetic concepts: –Program families, program fragments, and abstract classes –Separation of concepts Separating/encapsulating cross-cutting operations [Visitors] Mixin classes Reusable strategies and object-oriented frameworks –Reusable collaborations Software architecture and larger design issues Software process issues

K. Stirewalt CSE 335: Software Design Outline of course topics Foundational OO concepts Synthetic concepts: –Program families, program fragments, and abstract classes –Separation of concepts Separating/encapsulating cross-cutting operations [Visitors] Mixin classes Reusable strategies and object-oriented frameworks –Reusable collaborations Software architecture and larger design issues Software process issues

K. Stirewalt CSE 335: Software Design Synthetic OO Design Concepts & Reuse Lecture 6: Reusable, extensible collaborations Topics: – “Reusable units” of behavior – Interface classes – Readings from Gamma book: Observer and Adapter patterns – Homework 4 available on web

K. Stirewalt CSE 335: Software Design Problem: How to reuse behavior Suppose we want to design a GUI toolkit with widgets, such as Button, Slider, etc. Problem: –Class Button not very interesting by itself –Pressing the button should cause some operation to be invoked on some other object –But Button must know the class of this other object in order to invoke that operation –So how do we make Button reusable?

K. Stirewalt CSE 335: Software Design Running example Suppose we are given the class: class DocManager { public:... void printDocument(); void saveDocument();... }; which is responsible for opening, closing, saving, and printing text documents

K. Stirewalt CSE 335: Software Design Running example (continued) Now suppose we want to build a word-processing application: –Graphical user interface that allows, among other things, for users to save the file by clicking a “Save” button and to print the file by clicking a “Print” button. –Details of saving and printing are handled by the class DocManager Key problem: How to design class Button so that its instances can collaborate with instances of class DocManager

K. Stirewalt CSE 335: Software Design Running example (continued) print : Buttonmgr : DocManager Observe: Two instances and one link: “print button” of class Button “document manager” object of class DocManager Button press should invoke printDocument() operation Question: How might one design classes Button and DocManager to support this link? target

K. Stirewalt CSE 335: Software Design (Bad) design for class Button class Button { protected: DocManager* target; void monitorMouse() { … if( /* mouse click */ ) { target->printDocument(); } … } … }; Question: Why is this a bad solution?

K. Stirewalt CSE 335: Software Design Problem Observe: To invoke printDocument() operation, Button needed to know the class ( DocManager ) of the target object. However: –Button should not care that target is a DocManager –Not requesting information from target –More like sending a message to say: “Hey, I’ve been pressed!. Go do something!” Question: How can we design Button to send messages to objects of arbitrary classes?

K. Stirewalt CSE 335: Software Design Solution: Interface class class ButtonListener { public: virtual void buttonPressed( const string& )=0; }; Declares the messages an object must be able to handle to collaborate with a Button Defn: abstract class w/ nothing but pure virtual functions

K. Stirewalt CSE 335: Software Design Better design of class Button class Button { public: Button( const string& lab ) : label(lab), target(0) {} void setListener( ButtonListener* l ) { target=l; } protected: string label; ButtonListener* target; void monitorMouse() { … if( /* mouse click */ ) { if(target) target->buttonPressed(label); } … } }; Collaborator must register interest in press events Collaborator: any object that implements the ButtonListener interface

K. Stirewalt CSE 335: Software Design Question Now that class Button has been designed to send messages to instances of the interface class ButtonListener, how do we configure an application in which a button sends messages to a document manager?

K. Stirewalt CSE 335: Software Design Naive attempt at configuration... DocManager dm(...); Button print( “ Print ” ); print.setListener(&dm);... Question: Why does this statement fail to compile?

K. Stirewalt CSE 335: Software Design Adapter classes Multiple inheritance: Used to “glue” two (or more) existing classes to form a new class Useful for adapting a class (adaptee) to make its instances conform to some target interface: –New (adapter) class inherits publicly from both the adaptee class and the target interface class –Adapter class provides methods for target operations –These methods invoke adaptee operations –Instances of new class conform to both target and adaptee classes!

K. Stirewalt CSE 335: Software Design Adapter class in running example class MyDocManager : public DocManager, public ButtonListener { public: void buttonPressed( const string& s ) { if(s == “ print ” ) DocManager::printDocument(); } }; Button > ButtonListener DocManager MyDocManager target

K. Stirewalt CSE 335: Software Design Correct configuration int main(void) { Button printButton( “ print ” ); MyDocManager docMgr( … ); printButton.setListener(&docMgr); … return FL::run(); // GUI-toolkit event loop }

K. Stirewalt CSE 335: Software Design Qualities of this design Class Button very reusable We can understand the Button — ButtonListener collaboration with little knowledge of Button and no knowledge of DocManager –Example of separation of concerns Clear mechanism for adapting arbitrary class to implement the ButtonListener interface Program structured differently from programs that “compute a function”

K. Stirewalt CSE 335: Software Design Abstraction Defn: Process by which we identify the important aspects of a phenomenon and ignore its details Example: –STL class vector vs bounded sequence –The latter is an abstraction Two popular abstractions over objects: –Classes: groups set of objects with same characteristic –Collaborations: groups set of sets of objects that collaborate by sending messages back and forth to achieve some goal or purpose