• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/12

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

12 Cards in this Set

  • Front
  • Back

Template Method

purpose & example


  • Purpose: abstract out common behaviors

  • Web UI dashboard w/ content panels
  • Panel => shares the getUser(), and build() operations
  • GradesPanel => overloads the getTitle(), getBody(), getColor() operations

Composite pattern

purpose & example


  • purpose: perform opts on both primitive & composite in same way

  • file system
  • file => primitive
  • directory => composite
  • abstractFile => component/interface

Proxy pattern

purpose & example


  • purpose: provide a placeholder or surrogate for some other object in order to control access when costly (time, memory, etc)

  • Document editor (loading images costly)
  • TextDocument, getProxyImage() (in memory)
  • ImageProxy, name, getRealImg() (memory)
  • Image : imageData (on disk)

Iterator pattern

purpose & example


  • purpose: traverse a collection and access its elements without exposing structure

  • PHP: foreach( obj in collec ) {}
  • JS: ._each( rows, function(row){} )
  • CF: for( row in rows ) {}

Mediator pattern

purpose & example


  • purpose: encapsulate how objects interact with each other (complex interactions)

  • air traffic control tower

What is TIMPC?

Template, Iterator, Mediator, Proxy, Composite

What design principals with Template?


  • Open/Close
  • Inversion of Control (abstract calls subclass method)

What patterns are used with Template?

  • Inheritance
  • Composition with strategy (example game class calls print)

What are some types of proxies?


  • remote: local placeholder for remote thing
  • virtual: creates objects on demand
  • protection: access control to an object smart
  • smart reference: performs additional things when object is accessed (pass-thru functions)

What type of proxy is a variant on the Adapter pattern?

SMART REFERENCE


interposes extra function between proxy and realSubject

What are the common operations in an ITERATOR interface?


  • Current() - points to a specifc element
  • Next() - moves itself to next element
  • Reset() - sets to starting element
  • IsEnd() - detects if end of collection


Why use a mediator pattern?

  • Limits subclassing - localizes behavior
  • Decouples colleagues, encourages reuse
  • Simplified interactions, m2many to m2one
  • Abstracts cooperation
  • Centralized controll