architecting applications for multiple ui technologies · • architecting applications to support...
TRANSCRIPT
![Page 1: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/1.jpg)
ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES
Matt WoodwardPrincipal IT Specialist, United States Senatewww.mattwoodward.com/blog
#SA3C, RIA: Flex/AJAX/AIR
![Page 2: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/2.jpg)
What We’ll Cover• Architecting applications to support
multiple user interface (UI) technologies• Layered approach to architecture• Separation of concerns in application
layers• Tight cohesion and loose coupling in
objects• Importance of the service layer
![Page 3: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/3.jpg)
What We Won’t Cover• The basics of OO development
– I’m happy to answer specific questions as we go, but I won’t be covering any OO-101 type materials
3
![Page 4: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/4.jpg)
Who Am I?• I’ll ignore the deeper philosophical implications and give you
the basics ...• Principal IT Specialist, Office of the Sergeant at Arms, United
States Senate• ColdFusion Developer since 1997
– Also dabble in Flex and Java• Mach-II Release Coordinator• Manager, Capitol Hill User Group• Member of the Open BlueDragon Steering Committee• Adobe Community Expert for ColdFusion• Co-Host, ColdFusion Weekly Podcast
4
![Page 5: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/5.jpg)
Agenda• Overview of layered OO architecture in CF
applications• Discussion of domain modeling and the
importance of the business logic layer• Importance of detaching your business
logic from any particular UI or framework• Examine a simple contact manager
application
5
![Page 6: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/6.jpg)
Layered Application Architecture“There’s Pasta in My Software!”
![Page 7: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/7.jpg)
Spaghetti• No matter how you try to dress it up, just plain nasty
7
![Page 8: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/8.jpg)
Spaghetti with Meatballs• Better, but still a little scary
8
Spaghetti:Now with CFCs!
![Page 9: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/9.jpg)
Lasagne• Elegant, refined ... the ultimate goal
9
![Page 10: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/10.jpg)
The Layers (Mmmm ... Lasagne)
10
User Interface/Presentation Layer
Controller Layer
Service Layer
Business Logic Layer
VC
MM
![Page 11: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/11.jpg)
Master Your DomainNo, that’s not what I meant ...
![Page 12: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/12.jpg)
The Domain Model• Wikipedia: “... conceptual model of a
system which describes the various entities involved in that system and their relationships”
• Objects, attributes, and methods– objects = nouns– methods = verbs
• Spend a lot of time here!– think before you code
12
![Page 13: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/13.jpg)
Example Domain Model• Contact management system• Think about what objects are involved and
how they relate to one another• Use UML to think things through
– easy to change things on a diagram– much harder to change (and you’ll be more
reluctant to change) once you write code
13
![Page 14: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/14.jpg)
Where’s the Database?
14
![Page 15: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/15.jpg)
The Database Isn’t Important• OK, it is important, but not as important as
some people think it is• It’s where you store your data, but it does
NOT drive your application design• On the application side, think in objects• Worry about the database design once you
have your domain model completed
15
![Page 16: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/16.jpg)
Cohesion and Coupling• VERY. IMPORTANT. CONCEPTS.• Cohesion: the degree to which an object
does one thing and does it well• Coupling: the degree to which objects
depend upon one another• Strive for high cohesion and loose
coupling
16
![Page 17: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/17.jpg)
Peeling Back the LayersEach one is more delicious than the one before it
![Page 18: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/18.jpg)
Business Logic Layer• This is the most important part of your
application• This is where you spend most of your
development time• Separate and protect it from the outside
world– sheltered is good in this case!
• Make this work as reusable as possible
18
![Page 19: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/19.jpg)
Business Logic Layer (cont.)• Your business logic layer should not know
or care who’s talking to it (security concerns aside)
• Your business logic layer should NOT expose any details about HOW it does what it does
• Your business logic layer should only expose the bare minimum needed by the outside world to talk to it
19
![Page 20: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/20.jpg)
Business Objects• Tight cohesion and loose coupling mean
you will likely have ...– beans (the “nouns” in your system)– data access objects (DAOs/Gateways)– potentially other business objects, UDFs, etc.
• Make sure each object does one thing and does it well
• Make sure each object doesn’t have to know much about any other object
20
![Page 21: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/21.jpg)
Quick Look at Business Objects• Code samples of beans and data access
objects
21
![Page 22: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/22.jpg)
The Service Layer• Your business logic’s receptionist
22
![Page 23: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/23.jpg)
The Service Layer (cont.)• If someone wants to talk to your business
logic layer, they shouldn’t have a direct line of communication– remember loose coupling--you don’t want
outside objects knowing too much• Service layer is absolutely critical for the
reusability of your business logic layer• Think of the service layer as a public API to
your business logic layer23
![Page 24: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/24.jpg)
Service Layer in Action
24
• You don’t want anyone talking to your business logic directly
![Page 25: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/25.jpg)
The Controller Layer• We won’t spend much time on this, but
realize that there’s actually one more layer involved
• Controller layer can be ...– roll your own– framework like Mach-II, Model-Glue, Fusebox– Flex is more or less its own controller, but
there are also frameworks for Flex
25
![Page 26: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/26.jpg)
The User Interface Layer• If you’ve architected your application in a
layered way, and used a service layer, you can pick your UI poison
• All UIs talk through their controllers to the service layer
• In the case of Flex, AJAX, web services, etc. it may make sense to have a remote proxy on top of the service layer
26
![Page 27: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/27.jpg)
Remote Proxy• Used to expose only certain methods from
the service layer as remote• Can better handle the specific needs of
asynchronous calls from AJAX and Flex• Keeps your service layer nice and clean
– doesn’t know or care who’s talking to it
27
![Page 28: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/28.jpg)
Putting It All TogetherWhere the Magic Happens
![Page 29: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/29.jpg)
Poetry in Motion
29
Service
DAO/Gateway Bean
Other Objects
![Page 30: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/30.jpg)
Contact Manager Application• Demo and Code• HTML, AJAX, and Flex all talking to the
same business logic with no rework!• Example of a remote proxy used for Flex
and AJAX
30
![Page 31: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/31.jpg)
Recap and Q&A
![Page 32: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/32.jpg)
Recap• With a little planning, architecting for multiple UIs
is pretty simple• Makes for good application architecture
regardless of your UI technology choice• Future-proof your application’s business logic• Remember:
– spend time working on your domain model– separation of concerns– tight cohesion and loose coupling
32
![Page 33: ARCHITECTING APPLICATIONS FOR MULTIPLE UI TECHNOLOGIES · • Architecting applications to support multiple user interface (UI) technologies • Layered approach to architecture •](https://reader034.vdocuments.us/reader034/viewer/2022052014/602b4b4884e88447a91b2e61/html5/thumbnails/33.jpg)
Questions?• Thanks!• Matt Woodward
[email protected]://www.mattwoodward.com/bloghttp://www.coldfusionweekly.com
33