Patterns for Decoupling Data Structures and Algorithms or How visitors can help you grow! Stephen Wong, Oberlin College Dung “Zung” Nguyen, Pepperdine.

Slides:



Advertisements
Similar presentations
COM vs. CORBA.
Advertisements

SIGCSE 2005, St. Louis, MO Design Patterns for Recursive Descent Parsing Dung Nguyen, Mathias Ricken & Stephen Wong Rice University.
Design Patterns for Self-Balancing Trees Dung “Zung” Nguyen Stephen Wong Rice University.
Design Patterns for Marine Biology Simulation Dung “Zung” Nguyen Mathias Ricken Stephen Wong Rice University.
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
Preliminaries Attendance sheets –I remembered! Survey links –HW1 time survey –Anonymous feedback survey HW discussion (4PM, Commons 9)
No homework this week Stage 2 starts next week. Code review Team with N members is assigned N submissions to review Discuss submissions within team Everyone.
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
Lists We’ve seen an array-based list implementation, the ArrayList. Advantage of an array-based implementation: –fast access to a specific index –typically.
Lists We’ve seen an array-based list implementation, the ArrayList.
Design Pattern – Bridge (Structural) References Yih-shoung Chen, Department of Information Engineering, Feng Chia University,Taiwan, R.O.C. The Bridge.
Use Case Analysis – continued
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
C++ fundamentals.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Introduction to Object-oriented Programming CSIS 3701: Advanced Object Oriented Programming.
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
COMP 410 & Sky.NET May 2 nd, What is COMP 410? Forming an independent company The customer The planning Learning teamwork.
4/2/03I-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Software Architecture and Design Readings: Ambler, Chap. 7 (Sections to start.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Database Management System Prepared by Dr. Ahmed El-Ragal Reviewed & Presented By Mr. Mahmoud Rafeek Alfarra College Of Science & Technology Khan younis.
Tech Talk Go4 Factory Patterns Presented By: Matt Wilson.
Copyright © Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy. All rights reserved. Architectural Styles Part I Software Architecture Lecture 5.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 4, Requirements Elicitation.
Y2 eProjects Session 4 – Advanced Topics. Objectives  Dynamic Models  Design Patterns (Optional)  Software testing (for S4) ACCP i7.1\Sem3_4\eProject\T4.
Component Technology. Challenges Facing the Software Industry Today’s applications are large & complex – time consuming to develop, difficult and costly.
Computer Science 340 Software Design & Testing UML Sequence Diagrams.
Design Patterns for Self-Balancing Trees Dung “Zung” Nguyen Stephen Wong Rice University.
OOP in Introductory CS Stephen Wong and “Zung” Nguyen Rice University Better students though abstraction.
1 © Prentice Hall, 2002 Chapter 14: Object-Oriented Data Modeling Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R.
Strategy Design Patterns CS 590L - Sushil Puradkar.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
Design Patterns for Sorting Teaching something old in a new light Dung “Zung” Nguyen Stephen Wong Rice University.
Marine Biology Simulation Part II: Assignment, Milestone 1 Dung “Zung” Nguyen Mathias Ricken Stephen Wong TeachJava 2004! June 25, 2004.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
Design Patterns for Marine Biology Simulation Dung “Zung” Nguyen Mathias Ricken Stephen Wong Rice University.
Nifty Assignments: Marine Biology Simulation OOPSLA ‘04 Educators’ Symposium October 25, 2004 Eric Cheng Mathias Ricken Dung “Zung” Nguyen Stephen Wong.
Part VII: Design Continuous
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Data Abstaraction Chapter 10.
Design Patterns David Talby. This Lecture Re-routing method calls Chain of Responsibility Coding partial algorithms Template Method The Singleton Pattern.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
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.
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
Patterns for Decoupling Data Structures and Algorithms Dung “Zung” Nguyen Pepperdine University / University of Houston Stephen Wong Oberlin College
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
04 - OOD Intro.CSC4071 Software Design ‘Requirements’ defines –The goals the system needs to satisfy. ‘Specification’ defines –The externally-observable.
CSIS 4850: CS Senior Project – Spring 2009 CSIS 4850: Senior Project Spring 2009 Object-Oriented Design.
Computer Science Topical Paper Presentation #03 Adam Coffman The Cascading Bridge C a s c a d i n g B r i d g e – P a g e 1 The Cascading Bridge.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
Design Patterns: MORE Examples
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Design Patterns for Sorting Teaching something old in a new light
System Programming and administration
Behavioral Design Patterns
Design Patterns for Sorting something old in a new light
Data Structures and Database Applications Abstract Data Types
Presented by Igor Ivković
Design Patterns for Self-Balancing Trees
Design Patterns for Self-Balancing Trees
Design Patterns for Sorting Teaching something old in a new light
Design Patterns for Self-Balancing Trees
Nifty Assignments: Marine Biology Simulation
Marine Biology Simulation Part III: Assignment, Milestone 2
Design Patterns for Recursive Descent Parsing
Design Patterns for Self-Balancing Trees
Strategy Design Pattern
Design Patterns for Self-Balancing Trees
OOPSLA ’04 Educator’s Symposium
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Presentation transcript:

Patterns for Decoupling Data Structures and Algorithms or How visitors can help you grow! Stephen Wong, Oberlin College Dung “Zung” Nguyen, Pepperdine University

Where were we anyway? *Abstracting the structure and behavior of a linear recursive structure (“LRS” or “list”): *Empty vs Non-Empty States *State Transitions *State Design Pattern *Single LRS class that changes states. *Intelligent states that can handle themselves. First, the invariant behaviors…

UML Diagram of a LRS The public listThe abstract state The empty state The non-empty state

Object-Oriented Data Structures Represent the pure behavior of the structure of the data, independent of the data itself. Let’s take a look when we add the variant behaviors…

UML Diagram of a LRS Variant behaviors declared and accessed here Passed through this interface Executed here Or here

What’s wrong with this picture? *Why are the variant behaviors coded together with the invariant behaviors? *But aren’t the variant behaviors still the domain of the data structure object? *But who can predict future behavioral needs? *We need extensibility. *We need to de-couple the variant algorithms from the data structure. Now let’s fix it!

The Issue of Extensibility *Modern software engineering is driven by a need to handle change: *Code will be modified many times. *New features will be added on short intervals. *The complexity of modern system demands adherence to strict protocols. *Proper abstraction is crucial. *Need public interfaces that allow for expansion.

Examples of Extensible Programs *Netscape’s plug-ins. *MS Office’s add-ins and MS Active-X. *Dynamic Link Libraries (DLL’s). *I/O drivers But none of these can handle multiple hosts with different needs…. All of these can handle multiple extensions... Why shouldn’t they??

Designing for the Unknown *Identify the variant and invariant behaviors. *Encapsulate the invariant behaviors into a class. *Add hooks to this class to define communication protocols to other classes. *Encapsulate the variant behaviors into classes that comply with the above protocols.

The Visitor Design Pattern *Visitors *Encapsulate the variant behaviors. *All conform to a set invocation interface. *Provide different methods for different hosts. *Hosts *Provide a consistent “hook” for visitors. *Each different host calls only its desired method in the visitor.

Framework Control *Algorithm handed to the data structure rather than the other way around. *The data structure incapsulates the invariant behaviors and the algorithms are variant behaviors being added to it.

Visitors with a Common Interface Conforming algorithms Fixed visitor interface presents methods for each host.

Abstracted Hosts result = visitor.method1(this, param);result = visitor.method2(this, param);result = visitor.method3(this, param);User class calls for variant behavior in its abstract host: result = _host.visit(visitor, param); Each host calls its desired method

Binary Tree Structure Using the State Pattern Invariant behaviors plus a hook for the variant behaviors.

Binary Tree Structure Visitors

What Visitors Bring *Algorithms encapsulated separately from the data structure. *Invariant behaviors in the data structure. *Variant behaviors in the visitors. *Unlimited future capabilities. *Multiple host capable: Can handle state- dependent algorithms. *Recursive and non-recursive capable.

There’s more to come... *Recursive indexing schemes for arbitrarily branched tree structures. *Building a binary search tree using visitors. But not today…...

Growing with Visitors Bring on the visitors, for they bring abilities never before imagined.