Quick Overview <ul><li>You’re going to learn about a number of design patterns.  </li></ul><ul><li>You’re going to work ou...
Design Patterns… <ul><li>Are reusable solutions to common design problems </li></ul><ul><li>Improve the development workfl...
Design Patterns… <ul><li>are not Algorithms </li></ul><ul><li>are not Architectural Patterns  </li></ul><ul><li>are not fi...
Singleton Pattern <ul><li>The one and only </li></ul>
The Singleton Pattern… <ul><li>has only ONE instance  ever </li></ul><ul><li>is created only when needed </li></ul><ul><li...
Singleton Pattern Lab We’re going to implement an Asset Manager. Application Asset Manager Images Sound
Singleton Pattern Tips <ul><li>Use this pattern when you need  one and only one  instance of a class </li></ul><ul><li>The...
Command Pattern <ul><li>Execute Here     </li></ul>
The Command Pattern… <ul><li>encapsulates method invocation. </li></ul><ul><li>is a class used to carry out an ‘order’ </l...
The Command Pattern… <ul><li>Separating functionality into command classes makes it straight forward to implement complex ...
Command Pattern Lab <ul><li>Create Several Commands that encapsulate visual manipulations of your choice (rotate, scale, s...
Observer Pattern
The Observer Pattern… <ul><li>defines a one to many relationship between objects so when one object changes, all the obser...
Observer Pattern Lab Event Dispatcher Observer Observer Observer In this lab, we’re going to leverage the Observer Pattern...
Proxy Pattern <ul><li>May I Help You? </li></ul>
A Proxy… <ul><li>stands in for and provides access to another object. </li></ul><ul><li>can control or guard access </li><...
The Virtual Proxy <ul><li>The Virtual Proxy stands in for an object that  </li></ul><ul><li>is expensive to create </li></...
The Remote Proxy <ul><li>The Remote Proxy stands in for a remote object and,  </li></ul><ul><li>delegates requests to a re...
Proxy Pattern Lab <ul><li>In this lab, we’re going to implement a remote proxy and learn about a time saving technique. </...
Façade Pattern <ul><li>Hiding Complexity </li></ul>
Façade Pattern… <ul><li>The Façade pattern simplifies access to a collection of objects. </li></ul><ul><li>Often implement...
Adapter Pattern <ul><li>a.k.a. Wrapper </li></ul>
Adapter Pattern… <ul><li>The Adapter pattern converts and translates the API of one object to the API of another object. <...
Mediator Pattern <ul><li>Central Communication  </li></ul>
Mediator Pattern <ul><li>The Mediator Pattern is used to centralize complex communication and control between related obje...
Model View Controller <ul><li>A collection of patterns </li></ul>
Model View Controller (MVC) <ul><li>The MVC Pattern is a collection of patterns used to address the challenges presented b...
Model View Controller (MVC) <ul><li>MVC brings order to applications and application development by, </li></ul><ul><li>dec...
Quick Comparison <ul><li>Model </li></ul><ul><li>View </li></ul><ul><li>Controller </li></ul><ul><li>Command </li></ul><ul...
What I Like About PureMVC <ul><li>Platform & language independent  </li></ul><ul><ul><li>mobile, server, browser, desktop ...
PureMVC Conceptual Diagram
PureMVC - Model
PureMVC - View
PureMVC - Controller
PureMVC - Notifications
Good Practice <ul><li>Interfaces </li></ul><ul><li>Design Approach </li></ul><ul><li>Further Reading </li></ul>
Interfaces <ul><li>There are (hidden) two layers to every class you write </li></ul><ul><li>Interface </li></ul><ul><li>Im...
Designing Applications
Recommended Reading <ul><li>O’Reilly Head First Design Patterns </li></ul>
Upcoming SlideShare
Loading in …5
×

Design Pattern with Actionscript

3,011 views

Published on

Introduction to Design Patterns with Actionscript.

0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,011
On SlideShare
0
From Embeds
0
Number of Embeds
39
Actions
Shares
0
Downloads
0
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide
  • Design Pattern with Actionscript

    1. 2. Quick Overview <ul><li>You’re going to learn about a number of design patterns. </li></ul><ul><li>You’re going to work out some of them in code. </li></ul><ul><li>You’re going to apply most of the patterns we learn today towards an example Model View Controller application </li></ul>
    2. 3. Design Patterns… <ul><li>Are reusable solutions to common design problems </li></ul><ul><li>Improve the development workflow </li></ul><ul><li>Help teams to work together efficiently </li></ul><ul><li>Help you deal with change </li></ul>
    3. 4. Design Patterns… <ul><li>are not Algorithms </li></ul><ul><li>are not Architectural Patterns </li></ul><ul><li>are not finished designs </li></ul><ul><li>are not written in stone </li></ul>
    4. 5. Singleton Pattern <ul><li>The one and only </li></ul>
    5. 6. The Singleton Pattern… <ul><li>has only ONE instance ever </li></ul><ul><li>is created only when needed </li></ul><ul><li>assures that every object in an application is using the same resource (global access point) </li></ul>
    6. 7. Singleton Pattern Lab We’re going to implement an Asset Manager. Application Asset Manager Images Sound
    7. 8. Singleton Pattern Tips <ul><li>Use this pattern when you need one and only one instance of a class </li></ul><ul><li>The package mx.managers are all singletons </li></ul><ul><ul><li>DragManager </li></ul></ul><ul><ul><li>CursorManager </li></ul></ul><ul><ul><li>HistoryManager </li></ul></ul><ul><ul><li>FocusManager </li></ul></ul><ul><ul><li>etc… </li></ul></ul>
    8. 9. Command Pattern <ul><li>Execute Here  </li></ul>
    9. 10. The Command Pattern… <ul><li>encapsulates method invocation. </li></ul><ul><li>is a class used to carry out an ‘order’ </li></ul><ul><ul><li>authenticate user </li></ul></ul><ul><ul><li>process form </li></ul></ul><ul><ul><li>sit on cat </li></ul></ul><ul><li>often encapsulates an algorithm. </li></ul><ul><li>often performs tricky operations. </li></ul>
    10. 11. The Command Pattern… <ul><li>Separating functionality into command classes makes it straight forward to implement complex operations. </li></ul><ul><li>Undo and Redo </li></ul><ul><li>Queue or Pipeline </li></ul><ul><li>Deferred and transactional execution </li></ul>
    11. 12. Command Pattern Lab <ul><li>Create Several Commands that encapsulate visual manipulations of your choice (rotate, scale, swap display list location etc). </li></ul><ul><li>User gestures will execute these commands. </li></ul>
    12. 13. Observer Pattern
    13. 14. The Observer Pattern… <ul><li>defines a one to many relationship between objects so when one object changes, all the observers are notified. </li></ul><ul><li>is also known as Publish/Subscribe, and Listener. </li></ul><ul><li>is used in event driven design. </li></ul><ul><li>reduces coupling between classes, but they can still interact. </li></ul>
    14. 15. Observer Pattern Lab Event Dispatcher Observer Observer Observer In this lab, we’re going to leverage the Observer Pattern implementation built into the Flash Player.
    15. 16. Proxy Pattern <ul><li>May I Help You? </li></ul>
    16. 17. A Proxy… <ul><li>stands in for and provides access to another object. </li></ul><ul><li>can control or guard access </li></ul><ul><li>can be used to manage instantiation </li></ul>
    17. 18. The Virtual Proxy <ul><li>The Virtual Proxy stands in for an object that </li></ul><ul><li>is expensive to create </li></ul><ul><li>is not immediately available </li></ul><ul><li>The Loader class is a Virtual Proxy. </li></ul>DisplayObjectContainer Loader Sprite Stage MovieClip
    18. 19. The Remote Proxy <ul><li>The Remote Proxy stands in for a remote object and, </li></ul><ul><li>delegates requests to a remote object </li></ul><ul><li>manages communication with remote object </li></ul>Image Search Flickr API Remote PhotoProxy Remote Service Your Application
    19. 20. Proxy Pattern Lab <ul><li>In this lab, we’re going to implement a remote proxy and learn about a time saving technique. </li></ul>Image Search Flickr API Remote PhotoProxy Remote Service Your Application
    20. 21. Façade Pattern <ul><li>Hiding Complexity </li></ul>
    21. 22. Façade Pattern… <ul><li>The Façade pattern simplifies access to a collection of objects. </li></ul><ul><li>Often implemented as a singleton (only need one) </li></ul><ul><li>Hides the complexity of underlying objects </li></ul>Application Facade Model View Controller
    22. 23. Adapter Pattern <ul><li>a.k.a. Wrapper </li></ul>
    23. 24. Adapter Pattern… <ul><li>The Adapter pattern converts and translates the API of one object to the API of another object. </li></ul><ul><li>often applied when reusing legacy code </li></ul><ul><li>providing a common API to several 3 rd party libraries or algorithms </li></ul>Music Player MP3 Adapter FLAC Adapter AC3 Adapter FLAC Decoder MP3 Decoder WAV Decoder
    24. 25. Mediator Pattern <ul><li>Central Communication </li></ul>
    25. 26. Mediator Pattern <ul><li>The Mediator Pattern is used to centralize complex communication and control between related objects. </li></ul>Application Username Textbox Password Textbox Submit Button New Account Form Account Form Mediator
    26. 27. Model View Controller <ul><li>A collection of patterns </li></ul>
    27. 28. Model View Controller (MVC) <ul><li>The MVC Pattern is a collection of patterns used to address the challenges presented by rich user interfaces. </li></ul>
    28. 29. Model View Controller (MVC) <ul><li>MVC brings order to applications and application development by, </li></ul><ul><li>decoupling the user interface of an application from the data model and business logic. </li></ul><ul><li>allow each of the elements to be changed without impacting the other. </li></ul><ul><li>promotes reusability between UI components and data objects. </li></ul>
    29. 30. Quick Comparison <ul><li>Model </li></ul><ul><li>View </li></ul><ul><li>Controller </li></ul><ul><li>Command </li></ul><ul><li>Façade </li></ul><ul><li>Proxy </li></ul><ul><li>Mediator </li></ul><ul><li>Observer </li></ul><ul><li>Notification </li></ul><ul><li>Model </li></ul><ul><li>View </li></ul><ul><li>Controller </li></ul><ul><li>Command </li></ul><ul><li>Delegate </li></ul><ul><li>Service </li></ul><ul><li>CairngormEvent </li></ul>Cairngorm
    30. 31. What I Like About PureMVC <ul><li>Platform & language independent </li></ul><ul><ul><li>mobile, server, browser, desktop </li></ul></ul><ul><ul><li>AS2, AS3, ColdFusion, C#, Java, Perl, PHP, Python, more </li></ul></ul><ul><li>Excellent Documentation and Active Community </li></ul><ul><li>Programmed to Interfaces </li></ul><ul><li>Winner at SilvaFUG between 9 frameworks </li></ul>Cairngorm
    31. 32. PureMVC Conceptual Diagram
    32. 33. PureMVC - Model
    33. 34. PureMVC - View
    34. 35. PureMVC - Controller
    35. 36. PureMVC - Notifications
    36. 37. Good Practice <ul><li>Interfaces </li></ul><ul><li>Design Approach </li></ul><ul><li>Further Reading </li></ul>
    37. 38. Interfaces <ul><li>There are (hidden) two layers to every class you write </li></ul><ul><li>Interface </li></ul><ul><li>Implementation </li></ul>
    38. 39. Designing Applications
    39. 40. Recommended Reading <ul><li>O’Reilly Head First Design Patterns </li></ul>

    ×