SlideShare a Scribd company logo
C/C++ For Linux Session 10 C++ - Session 5
Outline STL Continued Functors, algorithms, strings, streams Very brief intro to boost Some design patterns
Functor Abstraction of anything callable Operator() Templatized by argument types Generator, unary, binary
Adapters An interface adapter binder mem_fun ptr_fun
Predicates A functor with a bool return value Why? Containers - Utilities algorithms
Common Algorithms find/search/equal_range replace/remove_if foreach sort
Strings Abstracts pointer manipulation Concat + Construct with char * c_str() Find, replace iterator
Streams Flow of characters Operators <<,>> Stream manipulation sstream iostream, cout/cin Fstream Your streams?
Boost www.boost.org Smart pointers foreach Bind Format any
Design patterns Problem repeats. Elements of the problem Elements of the solution Not code Independent of language Gamma et al,  Design Patterns: Elements of Reusable Object-Oriented Software http://www.vincehuston.org/dp/
Types of Patterns Creational:  The construction of objects Structural:  The mechanisms, the  What Behavioral: The internals of the object, the How Overlap, iterative design Interaction between types Refactoring
Factory Separate the creation of the object from the code operating on it. Abstract Factory:  Abstract object class + n concrete Abstract factory class + n concrete Client chooses which to create Factory Method: Abstract object class + n concrete A method (not ctor) creates the object based on parameter Perfect when client's choice is passable
Builder Complex creation, could build part or all at different times Elements: Abstract Object + n concrete Abstract Builder + n concrete buildPart, buildAll, getObject (Client chooses some object or some builder from director) (Director guides building) Consider data modeling with events
Other Creational Prototype:  New based on a copy  new operator  copy constructor Consider with a factory method Singleton:  GetInstance Static methods
Structural – Adapter Impedance matching – two separate interfaces Elements:  Adaptee with interface I1 Adapter with interface I2 Client uses I2 to perform function of I1 Where have we seen this?
Composite Hierarchy, e.g filesystem Elements: A Component interface A leaf, concrete of component A composite, concrete of component that has more leaves Natural creational pattern to create this?
Proxy Do something behind the scenes Elements: An abstract interface A real and imaginary imp Where have we seen this?
Aggregators Facade- Structural A simple unified interface for many other objects - delegation Where have we seen this? Mediator - Behavioral A unified interface for other components – interaction
Behavioral – Command A set of objects that get run/executed – decouple the content of cmds from manager Elements An abstract command – execute Different command imps Consider device management
Chain of Responsibility Hide the different decisions to act Elements Base handler – chained Derived handlers Handlers make a decision and take an action Beauracracy
Iterator Decouple iteration from container Elements: Pointer/Iterator Container Where have we seen this?
Observer Decouple actions from decision to act – scalability Elements: Facility/Subject with register & notify Abstract observer with update Concrete observers register Perfect for event handling What variant of this have we seen (w/out classes)?
State An OO state machine Elements: Subject with state and set_state Abstract state with trigger Concrete states whose triggers lead to action and setting next state Devices/Sockets Consider a stacked approach - aborts Why is this better than a table?
Strategy Decouple action content from action request – Imp-Interface model Elements: Abstract interface Implementations Best to choose interfaces outside client (so client stays same) Drivers Where have you “not” seen this?  Where have you done this?

More Related Content

ODP
Aspect-Oriented Programming
PDF
Lecture 7
PPTX
5.functions
PDF
Functions
PPTX
PPTX
2CPP18 - Modifiers
PDF
Functional Programming in Ruby
PDF
Lesson 3.2 data types for memory location
Aspect-Oriented Programming
Lecture 7
5.functions
Functions
2CPP18 - Modifiers
Functional Programming in Ruby
Lesson 3.2 data types for memory location

What's hot (19)

PPTX
Code quality
PPTX
Algorithm and pseudocode conventions
PPTX
XII Computer Science- Chapter 1-Function
PPT
Type Casting in C++
PPTX
Why system verilog ?
PPTX
Java 8 Functional Programming - I
PPT
C ppt
PDF
Introduction to Higher Order Functions in Scala
PPTX
Function
PDF
Python algorithm
PPTX
Presen 179
PDF
Intro to Functional Programming @ Scala Montreal
PPTX
Pure functions and usage in Angular
PPT
Type conversions
ODP
Pure functions
PPT
Verilog Tasks and functions
PPTX
Introduction To Algorithms
Code quality
Algorithm and pseudocode conventions
XII Computer Science- Chapter 1-Function
Type Casting in C++
Why system verilog ?
Java 8 Functional Programming - I
C ppt
Introduction to Higher Order Functions in Scala
Function
Python algorithm
Presen 179
Intro to Functional Programming @ Scala Montreal
Pure functions and usage in Angular
Type conversions
Pure functions
Verilog Tasks and functions
Introduction To Algorithms
Ad

Viewers also liked (9)

PDF
An Introduction to Part of C++ STL
PPT
Stl Containers
PPTX
E rate presentation
PPTX
Standard template library
PPT
2CPP16 - STL
PDF
The STL
ODP
Sysprog 9
PPTX
How to choose best containers in STL (C++)
PPT
standard template library(STL) in C++
An Introduction to Part of C++ STL
Stl Containers
E rate presentation
Standard template library
2CPP16 - STL
The STL
Sysprog 9
How to choose best containers in STL (C++)
standard template library(STL) in C++
Ad

Similar to Sysprog 10 (20)

PPT
Generalized Functors - Realizing Command Design Pattern in C++
PPTX
Oop2011 actor presentation_stal
PPTX
A Brief Conceptual Introduction to Functional Java 8 and its API
PDF
Carlo Bonamico, Sonia Pini - So you want to build your (Angular) Component Li...
PDF
Build Your Own Angular Component Library
PPT
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
PPTX
Play framework : A Walkthrough
PPTX
Angular2 and You
ODP
Can't Dance The Lambda
PPT
Software Architecture in Architecture design .ppt
PPT
myslide6
PPT
NewSeriesSlideShare
PPT
myslide1
PDF
react-slides.pdf
PDF
react-slides.pdf gives information about react library
PPTX
react-slides.pptx
PPT
PPTX
Code camp 2011 Getting Started with IOS, Una Daly
PPTX
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
PDF
C++ Interview Questions and Answers PDF By ScholarHat
Generalized Functors - Realizing Command Design Pattern in C++
Oop2011 actor presentation_stal
A Brief Conceptual Introduction to Functional Java 8 and its API
Carlo Bonamico, Sonia Pini - So you want to build your (Angular) Component Li...
Build Your Own Angular Component Library
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
Play framework : A Walkthrough
Angular2 and You
Can't Dance The Lambda
Software Architecture in Architecture design .ppt
myslide6
NewSeriesSlideShare
myslide1
react-slides.pdf
react-slides.pdf gives information about react library
react-slides.pptx
Code camp 2011 Getting Started with IOS, Una Daly
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
C++ Interview Questions and Answers PDF By ScholarHat

More from Ahmed Mekkawy (20)

PDF
Encrypted Traffic in Egypt - an attempt to understand
ODP
Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...
PDF
OpenData for governments
ODP
Infrastructure as a Code
PDF
شركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحة
PDF
Everything is a Game
ODP
Why Cloud Computing has to go the FOSS way
ODP
FOSS Enterpreneurship
ODP
Intro to FOSS & using it in development
PDF
FOSS, history and philosophy
ODP
Virtualization Techniques & Cloud Compting
ODP
A look at computer security
ODP
Networking in Gnu/Linux
ODP
Foss Movement In Egypt
ODP
Sysprog17
ODP
Sysprog 15
ODP
Sysprog 12
ODP
Sysprog 14
ODP
Sysprog 11
ODP
Sysprog 7
Encrypted Traffic in Egypt - an attempt to understand
Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...
OpenData for governments
Infrastructure as a Code
شركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحة
Everything is a Game
Why Cloud Computing has to go the FOSS way
FOSS Enterpreneurship
Intro to FOSS & using it in development
FOSS, history and philosophy
Virtualization Techniques & Cloud Compting
A look at computer security
Networking in Gnu/Linux
Foss Movement In Egypt
Sysprog17
Sysprog 15
Sysprog 12
Sysprog 14
Sysprog 11
Sysprog 7

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
Teaching material agriculture food technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
cuic standard and advanced reporting.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
gpt5_lecture_notes_comprehensive_20250812015547.pdf
A comparative analysis of optical character recognition models for extracting...
Advanced methodologies resolving dimensionality complications for autism neur...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Teaching material agriculture food technology
Chapter 3 Spatial Domain Image Processing.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Empathic Computing: Creating Shared Understanding
cuic standard and advanced reporting.pdf
Spectroscopy.pptx food analysis technology
sap open course for s4hana steps from ECC to s4
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
MIND Revenue Release Quarter 2 2025 Press Release
MYSQL Presentation for SQL database connectivity
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

Sysprog 10

  • 1. C/C++ For Linux Session 10 C++ - Session 5
  • 2. Outline STL Continued Functors, algorithms, strings, streams Very brief intro to boost Some design patterns
  • 3. Functor Abstraction of anything callable Operator() Templatized by argument types Generator, unary, binary
  • 4. Adapters An interface adapter binder mem_fun ptr_fun
  • 5. Predicates A functor with a bool return value Why? Containers - Utilities algorithms
  • 6. Common Algorithms find/search/equal_range replace/remove_if foreach sort
  • 7. Strings Abstracts pointer manipulation Concat + Construct with char * c_str() Find, replace iterator
  • 8. Streams Flow of characters Operators <<,>> Stream manipulation sstream iostream, cout/cin Fstream Your streams?
  • 9. Boost www.boost.org Smart pointers foreach Bind Format any
  • 10. Design patterns Problem repeats. Elements of the problem Elements of the solution Not code Independent of language Gamma et al, Design Patterns: Elements of Reusable Object-Oriented Software http://www.vincehuston.org/dp/
  • 11. Types of Patterns Creational: The construction of objects Structural: The mechanisms, the What Behavioral: The internals of the object, the How Overlap, iterative design Interaction between types Refactoring
  • 12. Factory Separate the creation of the object from the code operating on it. Abstract Factory: Abstract object class + n concrete Abstract factory class + n concrete Client chooses which to create Factory Method: Abstract object class + n concrete A method (not ctor) creates the object based on parameter Perfect when client's choice is passable
  • 13. Builder Complex creation, could build part or all at different times Elements: Abstract Object + n concrete Abstract Builder + n concrete buildPart, buildAll, getObject (Client chooses some object or some builder from director) (Director guides building) Consider data modeling with events
  • 14. Other Creational Prototype: New based on a copy new operator copy constructor Consider with a factory method Singleton: GetInstance Static methods
  • 15. Structural – Adapter Impedance matching – two separate interfaces Elements: Adaptee with interface I1 Adapter with interface I2 Client uses I2 to perform function of I1 Where have we seen this?
  • 16. Composite Hierarchy, e.g filesystem Elements: A Component interface A leaf, concrete of component A composite, concrete of component that has more leaves Natural creational pattern to create this?
  • 17. Proxy Do something behind the scenes Elements: An abstract interface A real and imaginary imp Where have we seen this?
  • 18. Aggregators Facade- Structural A simple unified interface for many other objects - delegation Where have we seen this? Mediator - Behavioral A unified interface for other components – interaction
  • 19. Behavioral – Command A set of objects that get run/executed – decouple the content of cmds from manager Elements An abstract command – execute Different command imps Consider device management
  • 20. Chain of Responsibility Hide the different decisions to act Elements Base handler – chained Derived handlers Handlers make a decision and take an action Beauracracy
  • 21. Iterator Decouple iteration from container Elements: Pointer/Iterator Container Where have we seen this?
  • 22. Observer Decouple actions from decision to act – scalability Elements: Facility/Subject with register & notify Abstract observer with update Concrete observers register Perfect for event handling What variant of this have we seen (w/out classes)?
  • 23. State An OO state machine Elements: Subject with state and set_state Abstract state with trigger Concrete states whose triggers lead to action and setting next state Devices/Sockets Consider a stacked approach - aborts Why is this better than a table?
  • 24. Strategy Decouple action content from action request – Imp-Interface model Elements: Abstract interface Implementations Best to choose interfaces outside client (so client stays same) Drivers Where have you “not” seen this? Where have you done this?