1 / 0

Lecture 27: Façade Pattern

Computer Science 313 – Advanced Programming Topics. Lecture 27: Façade Pattern. “In a Nutshell”. Commonly used English expression Means “in a few words” or “briefly” Summarizing idea with many details left out. “In a Nutshell”.

bayard
Télécharger la présentation

Lecture 27: Façade Pattern

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Science 313 – Advanced Programming Topics

    Lecture 27:Façade Pattern

  2. “In a Nutshell” Commonly used English expression Means “in a few words” or “briefly” Summarizing idea with many details left out
  3. “In a Nutshell” I could be bounded in a nutshell, and count my selfe a King of infinite space. Commonly used English expression Means“in a few words”or“briefly” Summarizing idea with many details left out
  4. “In a Nutshell” Usage can be traced back to 1608 Even before Hamlet used it Meaning has not changed in 400 years Also became a verb in that time “To nutshell” popularized by Mark Twain Any questions about what it means?
  5. “In a Nutshell” Usage can be traced back to 1608 Even before Hamlet used it Meaning has not changed in 400 years Also became a verb in that time “To nutshell” popularized by Mark Twain Any questions about what it means? Will someone explain this to O’Reilly!
  6. Big Picture for Façade Provide simple interface to low-level functions Create single class defining simple methods May combine functionality of multiple instances Façade makes client easier to write & use Packages tricky parts into simple method(s) Allows client to avoid working with many instances Nothing should change in lower level classes Using the façade complex subsystem hidden But still usable without going through façade
  7. Real-Life is Hard Real life is full of complex ideas & concepts Filling out your tax forms every April Rules for holding in (American) football Explaining why the sky is blue Appeal of soccer to billions worldwide
  8. Real-Life is Hard Often rely on simplicities to understand these Filling out your tax forms every April“Politician got bribe contribution to create deduction” Rules for holding in (American) football “Stay within the shoulder pads & don’t get caught” Explaining why the sky is blue“Wavelengths not scattered by the atmosphere” Appeal of soccer to billions worldwide“Excuse to drink beer & occasionally riot”
  9. Real-Life Façade Compiler is (real-life)example of façade Typically we think of compiler as single system Many complex systems combine to make compiler Code divided into tokens by the parser Lexigraphical analyzer computes tokens’ meanings Analysis improved & simplified by optimizer Code generator lowers & outputs result Even so, many of these systems also façades: Loop analyzer, SSA transform, peepholerin optimizer
  10. Façades On Computers
  11. Façade We Regularly Use Usually do all interactions via simple interface javac foo.java compiles class named foo But can also access components directly final& volatile provide details to optimizer Can get instance of javax.tools.JavaCompiler
  12. Façade We Regularly Use Compilation easy because of this façade Façade simplifies & allows messing with internals All skill levels helped using the compiler Beginner javacfoo.java Expert javac –g:nonefoo.java Stupid javac –nowarn –Xprintfoo.java
  13. Façade versus Adapter Façade and Adapter patterns very similar Enable simplifying code to be used by client Both patterns effectively hide subsystem details 1 or more instances behind exposed interface Idealized UML class diagram may/may notdiffer “What is the difference?” should be asked
  14. Intent Crucial to Usage Adapter makes existing code use interface Original implementation hidden by pattern Lets client code think class written for interface Adapts existing code so it can work in other places Façade used to create interface to use system Original implementation hidden by pattern Lets client write code as if design has simple interface Provides a false front for use in another system
  15. Clients of Façade & Adapter With either pattern within client code: No difference in usage No difference in design
  16. Using Façade & Adapter Façade Adapter Yams \ Sweet Potatoes
  17. Kissing Cousins of Patterns Adapter & Façadealso close to Decorator Structural patterns that help simplify client code Within each pattern, hide implementation details Workings invisible to those outside pattern Decorator has some important differences Decorations invisible; adapter & façade not Decorator requires specific class relationships Interface unchanged by decorator pattern
  18. For Next Class Lab #5 due on Friday Do not leave labs to last second Read pages 265 – 275 for Friday What is the Principle of Least Knowledge? How much of class already follows this principle? What is the Law of Demeter? Can we quantify this principle?
More Related