Wrapper Façade Pattern

Slides:



Advertisements
Similar presentations
Department of Computer Science and Engineering University of Washington Brian N. Bershad, Stefan Savage, Przemyslaw Pardyak, Emin Gun Sirer, Marc E. Fiuczynski,
Advertisements

Reasons to study concepts of PL
CS 3013 & CS 502 Summer 2006 Threads1 CS-3013 & CS-502 Summer 2006.
CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.
Design Patterns.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science Washington University, St. Louis
PRINCIPLES OF OPERATING SYSTEMS Lecture 6: Processes CPSC 457, Spring 2015 May 21, 2015 M. Reza Zakerinasab Department of Computer Science, University.
Programming Languages and Design Lecture 7 Subroutines and Control Abstraction Instructor: Li Ma Department of Computer Science Texas Southern University,
Real Time Programming Language. Intro A programming language represents the nexus of design and structure. But misuse of the programming language can.
Ontology Support for Abstraction Layer Modularization Hyun Cho, Jeff Gray Department of Computer Science University of Alabama
E81 CSE 532S: Advanced Multi-Paradigm Software Development Venkita Subramonian, Christopher Gill, Ying Huang, Marc Sentany Department of Computer Science.
Threads A thread is an alternative model of program execution
NCHU System & Network Lab Lab #6 Thread Management Operating System Lab.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Venkita Subramonian, Christopher Gill, Huang-Ming Huang, Shih-Ling Chen, Sajeeva Pallemulle.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Major OS Components CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
7/9/ Realizing Concurrency using Posix Threads (pthreads) B. Ramamurthy.
Tutorial 4. In this tutorial session we’ll see Threads.
Engineered for Tomorrow Unit:8-Idioms Engineered for Tomorrow sharmila V Dept of CSE.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
COMP7330/7336 Advanced Parallel and Distributed Computing Thread Basics Dr. Xiao Qin Auburn University
C++11 Atomic Types and Memory Model
Realizing Concurrency using the thread model
Threads Some of these slides were originally made by Dr. Roger deBry. They include text, figures, and information from this class’s textbook, Operating.
Appendix 1 - Packages Jim Fawcett copyright (c)
Component Configurator
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Presented by FACADE PATTERN
Introduction to Generic Programming in C++
Using Ada-C/C++ Changer as a Converter Automatically convert to C/C++ to reuse or redeploy your Ada code Eliminate the need for a costly and.
Classes and Objects: Encapsulation
Final Review David Ferry, Chris Gill
Event Handling Patterns Asynchronous Completion Token
Realizing Concurrency using the thread model
Week 2, Day 1: The Factory Method Pattern
Midterm Review David Ferry, Chris Gill
Multicore, Multithreaded, Multi-GPU Kernel VSIPL Standardization, Implementation, & Programming Impacts Anthony Skjellum, Ph.D.
Boost String API & Threads
CS399 New Beginnings Jonathan Walpole.
Multithreading Tutorial
Presentation by Omar Abu-Azzah
Principles of Operating Systems Lecture 8
Lecture 2 of Computer Science II
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Threads and Cooperation
Design Patterns in Operating Systems
Multithreading Tutorial
Advanced Programming Behnam Hatami Fall 2017.
Realizing Concurrency using Posix Threads (pthreads)
The Active Object Pattern
Typescript Programming Languages
Realizing Concurrency using the thread model
Multithreading Tutorial
Thread Programming.
Processes and Threads.
Half-Sync/Half-Async (HSHA) and Leader/Followers (LF) Patterns
Pthread Prof. Ikjun Yeom TA – Mugyo
Monitor Object Pattern
CS 350 – Software Design Principles and Strategies – Chapter 14
Multithreading Tutorial
Testing and Debugging Concurrent Code
Jonathan Walpole Computer Science Portland State University
Multithreading Tutorial
Realizing Concurrency using Posix Threads (pthreads)
Realizing Concurrency using the thread model
Adapter Design Pattern
Tutorial 4.
Oriented Design and Abstract Data Type
Interrupts and Interrupt Handling
Shared Memory David Ferry, Chris Gill
Presentation transcript:

Wrapper Façade Pattern E81 CSE 532S: Advanced Multi-Paradigm Software Development Wrapper Façade Pattern Chris Gill, Ryan Cooper, Gene Tien Department of Computer Science and Engineering Washington University, St. Louis cdgill@cse.wustl.edu Title slide

Wrapper Facade Combines related functions/data (OO, generic) pthread_create (thread, attr, start_routine, arg); pthread)_exit (status); pthread_cancel (thread); … thread thread (); thread (function, args); ~thread(); join(); … Contrast with Fascade Combines related functions/data (OO, generic) Used to adapt existing procedural APIs Offers better interfaces Concise, maintainable, portable, cohesive, type safe

Wrapper Façade Intent: Why? • To protect the application programmer from worrying about platform-specific API’s • To simplify use of the API’s (less tedious/error-prone) • To do this while paying only a small performance cost • Other related patterns have different intents Façade Decorator Bridge Adapter Simpifies -- encapsulates, type safety, maintainibility

Wrapper Façade Context: When? When extensibility can be achieved at a suitably low cost (vs. direct use of API) When extensibility is more important than performance improvements Other design patterns can give even more significant flexibility improvements, but the performance costs often increase as well E.g., the Extension Interface pattern

Wrapper Façade Context: Where? ACE_INLINE ACE_thread_t ACE_OS::thr_self (void) { // ACE_OS_TRACE ("ACE_OS::thr_self"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) // Note, don't use "::" here since the // following call is often a macro. ACE_OSCALL_RETURN (pthread_self (), int, -1); # elif defined (ACE_HAS_STHREADS) ACE_OSCALL_RETURN (::thr_self (), int, -1); # elif defined (ACE_HAS_WTHREADS) return ::GetCurrentThreadId (); # elif defined (ACE_PSOS) // there does not appear to be a way to get // a task's name other than at creation return 0; # elif defined (VXWORKS) return ::taskName (::taskIdSelf ()); # endif /* ACE_HAS_STHREADS */ #else return 1; // Might as well make it the first thread ;-) #endif /* ACE_HAS_THREADS */ } Most commonly used with networking, threading, and other low-level APIs

Wrapper Façade Implementation: How? (from POSA2) Identify cohesive abstractions and relationships among low level APIs E.g., “Every IPC SAP has a handle and every socket is an IPC SAP, but not every IPC SAP is a socket.”

Wrapper Façade Implementation, cont. 2. Cluster cohesive groups of functions into wrapper façade classes and methods 2.1 - Create cohesive classes 2.2 - Coalesce multiple individual functions into a single method (e.g., bind/listen) 2.3 - Automate creation and destruction 2.4 - Select level of indirection 2.5 - Determine where to encapsulate platform-specifics

Wrapper Façade Implementation, cont. 3. Consider allowing selective access to some implementation details, e.g., thread::native_handle_type tnht = t1.native_handle() is a “controlled violation of encapsulation.” 4. Develop error handling (language support for features such as exceptions may matter) 5. Define related helper classes, associated types, etc.

Common Problems and Issues Exceptions Language support Different ways of handling Resource management (e.g., C++ memory leaks) Overhead Loss of functionality Poor cross-language support Performance costs relative to application needs