This document discusses modular development in Flex using the Mate framework. It introduces common issues with large Flex applications, how modules can help address these issues, and provides an overview of the basics of the Mate framework. Mate uses inversion of control and dependency injection to promote a presentation pattern, making applications easier to maintain and extend through separation of concerns and loose coupling between components. The document outlines some of Mate's core features like the event map, property injection, and presentation model pattern.
2. What we will talk about ?
● Common Issues – What to watch out for
● Modules – Why and How
● Mate ( ma-tay ) - The Basics
● This Presentation is for people already looking at Flex
● This Presentation is mostly concepts
● Q&A
http://qld.cfug.org.au
3. Common Problems
● Flex
● Maintenance of hundreds of classes
● Getting Data to Nested Parts ( or Modules ) of your
Application
● Singleton
● Modules
● Sharing Events between Modules
● Sharing Data between Modules
● Populating with Data
http://qld.cfug.org.au
4. What are Modules ?
● Sub Applications compiled to SWF
files that can be loaded at runtime
http://qld.cfug.org.au
5. Why Modules ?
● Reduces size of individual applications
● Can be loaded Dynamically
● Can be “swapped out” for other Modules
● Separating your application into smaller parts can mean it
is Easier to Maintain
● Loading new Modules can mean it is easier for your Flex
app to grow
http://qld.cfug.org.au
6. What is Mate ?
● MXML / Flex Framework
● Inversion of Control / Dependency Injection
● Promotes “Presentation Pattern”
● Developed by ColdFusion Users
● Http : // mate.asfusion.com
http://qld.cfug.org.au
7. Mate has the fundamentals
● Injection of Properties and / or Classes to Views and
other Classes
● Event Dispatcher and Listener
http://qld.cfug.org.au
8. EventMap / LocalEventMap
● The Configuration MXML Files
● <EventMap> is Global
● Common uses
– For the Core of your application
– For Authentication
● <LocalEventMap> is Local
● Events are dispatched and Handled by scope.dispatcher
which is typically passed into the constructor of your
PresentationModel
● Common uses
– Modules
http://qld.cfug.org.au
9. Manager
● Is a Class to Manage your Data
● Common Uses
● Properties to inject your Data from your EventMap
● Functions to manipulate your Data from your Event Map
● Manager is typically not for
● Dispatching Events other than property change events for
binding
●
http://qld.cfug.org.au
10. Presentation Pattern
● Is a design pattern
● The most apparent aspect is the “Presentation Model”
● Using classes that are typically implemented for use by a
specific view, the presentation Model Encapsulates
– Interaction → Event Dispatch
– Model → View
● The Presentation Model Relies heavily on
● Access to data in your Managers
● Your Views having access to it
http://qld.cfug.org.au
11. Some of the EventMap Toolbox
● EventMap / LocalEventMap
● EventHandlers
● PropertyInjector
● EventInjector
● ObjectBuilder
● MethodInvoker / ServiceInvoker
http://qld.cfug.org.au
12. Event Handlers
● Used with Built in or Custom Events
● Common uses
● {FlexEvent.PREINITIALIZE}
● Custom Events ( {MyCustomEvent.CUSTOM} )
● Easy to Chain Events
http://qld.cfug.org.au
13. PropertyInjector
● For Injection of Properties to a View or a Registered Class
based on the Class Definition
● Removes need for Parents knowing about properties that
Children need
● Removes need for Singleton
● Makes dependencies easier to manage
● Works with Interfaces
● Works with Abstract Classes
● Example Scenario
● Inject Manager Properties into Presentation Model and
then Presentation Model into View
http://qld.cfug.org.au
14. EventInjector
● To setup function calls based on an Event.
● Example Scenario
● Change a View State based on an event ?
http://qld.cfug.org.au
15. ObjectBuilder
● For creating instances of Classes and to allow for
additional Injection techniques through
registerTarget=”true”
http://qld.cfug.org.au
16. MethodInvoker / ServiceInvoker
● Used to call internal / service functions from within other
Parent Tags such as EventHandler
● Example Scenario
● {TimesheetManager} / updateWorkingDays
● {MyCFService} / updateWorkingDays
http://qld.cfug.org.au
17. DataCopier
● Used to copy data from your Manager to a scope
accessible for further work in the EventMap
● Example Scenario
● {TimesheetManager} / WorkingDate
http://qld.cfug.org.au
18. Additional things
● Use <PropertyInjector softBinding=”true” … /> when
needing to Inject Global Properties to Modules
http://qld.cfug.org.au
19. Resources / Comments
● Very Active
● Lots of Examples
● Well Documented
● Although some best practices are hard to find
● Presentation Pattern is worth looking at
● Http : // mate.asfusion.com
http://qld.cfug.org.au