• Like
Sysprog 10
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Sysprog 10

  • 391 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
391
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
12
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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?