1 Design Patterns Delegates Visitor Pattern. 2 Observer Pattern Observer Pattern is an object-oriented design that simulates void-pointers in for instance.

Slides:



Advertisements
Similar presentations
Composite: Shapes Organisation State Observer Design Patterns.
Advertisements

CS  C++ Function Pointers  C# Method References  Groundwork for Lambda Functions.
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Interface COMP T1.
March Ron McFadyen1 Design Patterns In software engineering, a design pattern is a generally repeatable solution to a commonly-occurring problem.
Object-Oriented Analysis and Design
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
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.
Objects First with Java A Practical Introduction using BlueJ
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Programming in Scala Chapter 1. Scala: both object-oriented and functional Scala blends –object-oriented and –functional programming in a –statically.
Learning Ruby - 4 Ruby Code Blocks. Pay Attention - This is important! Code blocks in Ruby are not like “blocks of code” in other programming languages.
CO320 Introduction to Object- Oriented Programming Michael Kölling 3.0.
Templates. Objectives At the conclusion of this lesson, students should be able to Explain how function templates are used Correctly create a function.
Understanding class definitions Looking inside classes.
Blue’s Support for Object-Oriented Testing By: James Majidian Christopher Nersisyan.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Behavioral Patterns C h a p t e r 5 – P a g e 128 BehavioralPatterns Design patterns that identify and realize common interactions between objects Chain.
1 PH Chapter 1 (pp. 1-10) GoF Composite Pattern (pp ) PH Ch 2 through Fundamentals (pp ) Presentation by Julie Betlach 5/28/2009.
OOP Languages: Java vs C++
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
JVM And CLR Dan Agar April 16, Outline Java and.NET Design Philosophies Overview of Virtual Machines Technical Look at JVM and CLR Comparison of.
BCS 2143 Introduction to Object Oriented and Software Development.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
ADTs and C++ Ch 2,3,4 May 12, 2015 Abstract Data Type (ADT) An abstract data type is: 1.A collection of data items (storage structures) 2.Basic operations.
5.0 Objects First with Java A Practical Introduction using BlueJ Introduction to Computer Science I Instructor: Allyson Anderson.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Reactor Design Patterns: Command and Observer.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part V: Design The Design Workflow Design Classes Refining Analysis Relationships.
Programming Languages and Paradigms Object-Oriented Programming (Part II)
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Module 8: Delegates and Events. Overview Delegates Multicast Delegates Events When to Use Delegates, Events, and Interfaces.
Chapter 8: Aspect Oriented Programming Omar Meqdadi SE 3860 Lecture 8 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Data Parallelism Task Parallel Library (TPL) The use of lambdas Map-Reduce Pattern FEN 20141UCN Teknologi/act2learn.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Mid-Level Design Patterns: Iteration and Iterators.
FEN 2014UCN Teknologi/act2learn1 Higher order functions Observer Pattern Delegates Events Visitor Pattern Lambdas and closures Lambdas in libraries.
1.NETDelegates & eventsNOEA / PQC Delegates & events Observer pattern Delegates –Semantics –Cil – kode –Anvendelse Events.
From C++ to C# Part 5. Enums Similar to C++ Similar to C++ Read up section 1.10 of Spec. Read up section 1.10 of Spec.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
Written by: Dr. JJ Shepherd
Object Oriented Programming and Data Abstraction Rowan University Earl Huff.
1.NETDelegates & eventsNOEA / PQC 2007 Delegates & events Observer pattern Delegates –Semantics –Cil – kode –Anvendelse Events.
1.NETDelegates & eventsNOEA / PQC 2007 Delegates & events Observer pattern Delegates –Semantics –Cil – code –Usage Events Asynchronious delegates.
Development of a data acquisition program builder via a user interface F.Fujiwara, N.Tamura, M.Abe, S.Enomoto, G.Iwai, S,Kawabata, A.Manabe,Y.Nagasaka,
Lecture 8: Collections, Comparisons and Conversions. Svetla Boytcheva AUBG, Spring COS 240 Object-Oriented Languages.
Java for android Development Nasrullah Khan. Using instanceof in Android Development the classes such as Button, TextView, and CheckBox, which represent.
Scope and Code Generation
C++ Templates.
Objects as a programming concept
MPCS – Advanced java Programming
Interface Java 7 COMP T1.
Introduction to Design Patterns
Behavioral Design Patterns
Delegates and Events 14: Delegates and Events
Observer Design Pattern
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2005
Methods Attributes Method Modifiers ‘static’
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
C# Event Processing Model
6 Delegate and Lambda Expressions
Delegates & Events 1.
Lesson 7. Events, Delegates, Generics.
CS2011 Introduction to Programming I Objects and Classes
Computer Science 312 What’s New in Java 8? 1.
Generic Programming with Templates:
Modern Collections Classes & Generics
Creating and Using Classes
Presentation transcript:

1 Design Patterns Delegates Visitor Pattern

2 Observer Pattern Observer Pattern is an object-oriented design that simulates void-pointers in for instance C/C++ and higher order functions in for instance Pascal. In C# the language construct delegate provides some of the same possibilities.

Delegates A delegate is a language construct that facilitates passing methods as parameters to other methods. This can be done both for instance and class methods. This can be done across objects and classes. Delegates are object oriented and type safe. Actual, a delegate is an object which contains a collection of methods that may be invoked. 3

Observer Delegate These features can be used to implement call-back: View: code samplecode sample 4

Exercise Add a Realist to the example. A realist will act as a pessimist, if the bottle amount is less than 50 cl. and like an optimist otherwise. 5

Visitor Delegate Used for traversing a collection and changing elements without knowing anything about the internal structure of the collections. A sort of “mutator iterator” May be simulated using the Visitor Pattern (GoF 1995) 6 Collection y x z ModifyAll( ) public int Double(int x){ return 2*x; } View: code samplecode sample

Opgave Add methods to the Visitor example, so it is possible to increase all numbers greater than 20 in the container by 7. 7

Delegates are objects them selves. They inherit from System.Delegate via System.MulticastDelegate 8

Events Delegates are often used for event based systems The keyword event in C# makes this a little easier The mechanism behind is the same. A event is a sort of a delegate. Events are often used in object oriented GUI programs Events can be used with advantage in other areas such as simulation and real-time systems. 9