Design Patterns 1 2-29-2002.

Slides:



Advertisements
Similar presentations
CS 106 Introduction to Computer Science I 11 / 26 / 2007 Instructor: Michael Eckmann.
Advertisements

Design Patterns. What is a Design Pattern? Generic pattern for solving a certain class of problem Learn to recognize the class of problem and apply a.
Generics, Proxy, and The Compile Time Type Checking Debate You are either with us or against us. Please snarf the code for today’s class.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
CSCI-383 Object-Oriented Programming & Design Lecture 18.
Linked List. Iterators Operation to find a link, deleting, and inserting before or after a specified link, also involve searching through the list to.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Strategy Pattern.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
N ATIONAL E NERGY R ESEARCH S CIENTIFIC C OMPUTING C ENTER Charles Leggett Callbacks May
Interfaces About Interfaces Interfaces and abstract classes provide more structured way to separate interface from implementation
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Copyright © 2009 – Curt Hill Standard Template Library An Introduction.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Mr H Kandjimi 2016/01/03Mr Kandjimi1 Week 3 –Modularity in C++
OOP Details Constructors, copies, access. Initialize Fields are not initialized by default:
The Object-Oriented Thought Process Chapter 03
AP CSP: Creating Functions & Top-Down Design
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Presented by FACADE PATTERN
JavaScript/ App Lab Programming:
Chapter 5: Enhancing Classes
Object-Oriented Design
Andy Wang Object Oriented Programming in C++ COP 3330
Regular Expressions 'RegEx'.
Chapter 10 Design Patterns.
MPCS – Advanced java Programming
Design Patterns C++ Java C#.
Introduction to Design Patterns
Functions and Top-Down Design
The Object-Oriented Thought Process Chapter 1
Behavioral Design Patterns
Data Abstraction: The Walls
Design Patterns C++ Java C#.
OOP What is problem? Solution? OOP
Object-Oriented Programming & Design Lecture 18 Martin van Bommel
Object-Oriented Programming
Chapter 5 Conclusion CIS 61.
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Strategy Design Pattern
Interfaces and Inheritance
The dirty secrets of objects
CMPE212 – Stuff… Assn 3 due and Quiz 2 in the lab next week.
Advanced Programming Behnam Hatami Fall 2017.
Jim Fawcett CSE776 – Design Patterns Summer 2003
CISC124 Assignment 4 on Inheritance due next Monday, the 12th at 7pm.
CISC101 Reminders Slides have changed from those posted last night…
Week 6 Object-Oriented Programming (2): Polymorphism
Making Procedural Methods
UNIT 3 CHAPTER 1 LESSON 4 Using Simple Commands.
Fall 2018 CISC124 12/3/2018 CISC124 or talk to your grader with questions about assignment grading. Fall 2018 CISC124 - Prof. McLeod Prof. Alan McLeod.
Advanced Java Programming
Object Oriented Practices
Unit 3: Lesson 6 & 7- Functions and Top-Down Design / APIs and Function Parameters Day 27.
Dr. Bhargavi Dept of CS CHRIST
Arrays
CISC/CMPE320 - Prof. McLeod
Defining Classes and Methods
Java Inheritance.
Structural Patterns: Adapter and Bridge
CISC124 Assignment 3 sample solution will be posted tonight after 7pm.
CIS 199 Final Review.
Polymorphism 2019/4/29.
CS2013 Lecture 7 John Hurley Cal State LA.
Code Generation Tips Tricks Pitfalls 5/4/2019 A.Symons CiTR Pty Ltd.
Winter 2019 CMPE212 5/25/2019 CMPE212 – Reminders
CMPE212 – Reminders Assignment 2 due next Friday.
ENERGY 211 / CME 211 Lecture 22 November 10, 2008.
C++ Object Oriented 1.
Presentation transcript:

Design Patterns 1 2-29-2002

Opening Discussion What did we talk about last class? Do you have any questions about assignments? Did you do the reading? What are design patterns? What do they help us with? What are the patterns that were in the reading for today? Templates and separate compilation in C++.

Design Patterns Certain things that you want to do in programs come up repeatedly. General solutions to these are often called design patterns. Understanding and being able to use design patterns can make your life programming easier, but they are not without their pitfalls as the code to do them can be complex at times.

Functors Classes that have no data are sometimes called functors. Especially if they have only one method in them and they are used as arguments to templated functions. A functor class allows the flexability of easily passing a function as an argument to another function. This can be helpful for things like sorting on different keys.

Writing Functors You can have a functor where the method is a normal method with some appropriate name. This is how you would do it in most OOPLs. In C++ you have the ability to overload the function call operator, operator(), to take different numbers of different types of arguments. When you invoke these you use the functor like a function.

Wrappers Sometimes you want to add an extra layer of abstraction on top of a given data type. This is most common when the data type is a primitive and the default behavior isn’t exactly what you want it to do. With a wrapper class you create a class that stores the primitive type, but has a more appropriate interface for doing what you want it to do.

Adapters At times you might have a class that does something you want, but the interface on it isn’t quite right. This could be especially true if you are going to use it with templates and the template functions or classes require certain methods of the class. An adapter uses private inheritance to put a new interface over the old one.

Details All of these patterns we discussed today gain significance from templates. In some cases they are things that you wouldn’t want to even do without templates (adapters). In others, the templates make them fast and efficient (functors).

Minute Essay We might have a use for functors in the project so that you can have a sorted list that gets sorted on different aspects of SubStr. It might even be helpful for assignment #3. Write a functor class where the method takes two SubStr objects and compares them in some way. Remember that the design for assignment #3 is due today.