1. Scaling the Cairngorms One Way Up the Mountain Test-Driven Flex and ArcGIS Server Development Utilizing Cairngorm 3
2. Your Sherpa Glenn Goodrich Enspiria Solutions ggoodrich@enspiria.com @ruprictGeek
3. Pragmatica Destination: Summit of Pragmatica Build good practices like TDD, IoC, DI and make a MOCKery of unmaintainable development.
4. What’s on our backs? Flex API Cairngorm 3 FlexUnit 4 Parsley ASMock Hamcrest
5. Who are you? Previous Climbing Experience Flex Developer Understand TDD, IoC/DI Understand Mocking Bonus Cairngorm experience Other MVC experience
6. Base Camp: Cairngorm Micro-Architecture Command Pattern IoC to Inject Models & Services Guidelines Tools Libraries We are here NOTHING like Cairngorm 2. (Really, like, they are TOTALLY different)
7. Base Camp: Cairngorm Guidelines Application Layers Presentation Application Domain Infrastructure Presume IoC, but don’t specify Loose Coupling NOTHING like Cairngorm 2. (Really, like, they are TOTALLY different)
8. Base Camp: Cairngorm Guidelines Presentation View and View Models MXML has minimal script MXML binds to Model MXML throws inline events View Model throws business events Application Events & Commands Integrate to the world Changes Model Domain Business Objects Business Logic (Client-side) Infrastructure Services, Remote & Local (cache)
9. Base Camp: Cairngorm Guidelines Cairngorm Messaging event event Infrastructure View => PM Command invokes returns updates binds to Model
10. Base Camp: Cairngorm Tools Leverage Existing Libraries FlexUnit4 ASMock FlexPMD IDE Plugins Pretty sparse, right now. IDE Integration could be the only place Cairngorm 3 is like Caringorm 2
11. Base Camp: Cairngorm Libraries Integration Observer Validation Navigation Module Task PopUp Think Patterns & Practices Provide framework Handle common needs
12. Base Camp: Cairngorm Libraries public class SelectStadiumsCommand { [Inject] public varservice:IStadiumService; [Inject] public varselectedStadiums:Stadiums; [Command(selector="selectStadiums")] public function execute(event:SelectStadiumsEvent):AsyncToken{ return service.getStadiumsForGeometry(event.geometry); } [CommandResult(selector="selectStadiums")] public function handleStadiums(result:*,event:SelectStadiumsEvent):void{ //Transform result Integration Command Pattern Global Error Handling Progress Information
13. Base Camp: Cairngorm Libraries Observer Data binding Don’t use this (unless you have to) <observer:Observe source="{model.selectedExtent.xmin}“ handler="updateExtent"/>
18. Base Camp: Parsley & SpiceLib Parsley Dependency Injection Messaging Task Framework SpiceLib Submodule of Parsely Reflection Task Framework
19. Pragmatica Need The Cairngorms are the last place on earth where the NFL hasn’t played a football game. The leaders of Pragmatica want to lure the NFL to Scotland and need a way to select the different stadiums and learn about these “football” teams.* User Story As a Pragmatica Leader, I want to select specific NFL Stadiums so I can see what makes a good stadium. * *worst contrived presentation demo story ever
20. The Foot of the Summit Data Base Map NFL Stadiums (via GeoCommons) Special Instructions Compiler setting for ASMock/FlexUnit4 runner Create “test” folder for our unit tests
21. The Foot of the Summit Source Structure Broken into Functional Areas Separate test folder
22. First Belay: Write a Test FlexUnit4 Setup Test Suite (Scaling Tests) TestRunner Application User Story As a Pragmatica Leader, I want to select specific NFL Stadiums so I can see what makes a good stadium. Map Test User draws a polygon Map fires event (SelectStadiumsEvent)
26. Second Belay: Write a Test Command Test Should call a service Should update model with results Application Layer Shields view from Infrastructure Changes Model Drives the Model Stadium Stadiums
27. Second Belay: Under Test Cairngorm Messaging Infrastructure Command invokes returns updates Model
36. Race to the Summit Pragmatica Rinse, Lather, Repeat Write Tests Write Code to Satisfy Tests Hook up Views Configure IoC Some Other Examples Stadium Map Show PopUp
37.
38.
39.
40. Back at Base Camp Presentation on SlideShare http://slideshare.net/ruprict/scaling-caringorms Source Code on GitHub http://github.com/ruprict/scaling-cairngorm-ags Links to all libraries Contact Me ggoodrich@enspiria.com @ruprictGeek
Flex work for >2 yearUsed Cairngorm 2 on a couple of projectsThis presentation focuses on Cairngorm 3, which is in beta
Goal: To get to Base Camp Pragmatica where maintainable, clean Flex apps are the norm.
Cairngorm 3 – the frameworkFlexUnit4 – TDDSpicefactory/Parsley – IoC, messagingAGS Flex API - MapsHamcrest – MatchersASMock – Mock framework
Cairngorm 3 – the frameworkFlexUnit4 – TDDSpicefactory/Parsley – IoC, messagingAGS Flex API - MapsHamcrest – MatchersASMock – Mock framework
Cairngorm 3 is still in betaI recommend using it b/c it's cleaner, easier to test & maintain"Microarchitecture" to develop RIAsWhile some of the Cairngorm 2 patterns are still around, much of what was wrong with Cairngorm 2 is gone.Command pattern is still hereIOC is goneHas a set of Guidelines, Tools, and Libraries to help describe and support this microarchitecture
Split the application into functional areas.In larger applications, you would split the functional areas into modules, and each FA would have layersPresume IoC, but don't specify a provider. This is the heart of Cairngorm 3's adaptability. The example implementation is written using Parsley and SpiceLibVERY different from Cairngorm 2
Layout application (or modules) into the these four functional areas
Layout application (or modules) into the these four functional areas