DESIGN PATTERNS AND COLDFUSION EXPLORING OBJECT BASED PROGRAMMING
DESIGN PATTERNS AND COLDFUSION: EXPLORING OBJECT BASED PROGRAMMING Dan Blackman www. muddbrick. com
Dan Blackman • Founder and Senior Consultant – – Mudd Brick Inc, Dallas, Tx • Certified Adobe Instructor – Flex, Cold. Fusion, Flash • Experience – 12 Years Cold. Fusion, Flash and Flex
Setting Expectations • I am not a Architect but I play one on TV • My name does not end in Lehman, Forta, Majano etc. • There will be NO debate here today…Just demystification of a cryptic topic. • Let’s have an interactive dialog
Objectives • • • Design Patterns: The Why? Identification of Core Design Patterns Frameworks Shut up and Show me some code!!! Summary and Questions
Design Patterns: The Why!? What is the main goal of building Cold. Fusion/ Flex Applications?
Design Patterns: The Why? SOA –Service Oriented Architecture Mind the Gap - Marcel Boucher http: //blogs. adobe. com/mtg/2008/04/implementing_soa_principals_in. html Duane Nickul, et al http: //www. adobe. com/enterprise/pdfs/Services_Oriented_Architecture _from_Adobe. pdf
Design Patterns: The Why? SOA –Service Oriented Architecture The ultimate value of SOA is the ability to combine automated business services to create new market offerings that may reduce time-to-market and development costs. " Terry Borden and Bill Mitlehner
Design Patterns: The Why? SOA
Design Patterns: The Why? • FACT: Refactoring patterns into existing code is much more difficult than writing an application correctly the first time.
Design Patterns: The Why • Scalability – Can your application support a large number of concurrent users? • Maintainability – the everyday fight we have with our inner-self and management. • Reusability – Break down your application into small chunks. Forces us to build structure into our applications.
Design Patterns: The Why Let’s look at some Spaghetti Code: Most of you have written code like this!!!
Design Patterns: The Why MORAL of the STORY? An Architect does not construct a building with out a blueprint, Why are YOU then, building applications without a solid foundation? Me
Identification of Core Design Patterns What are design patterns and how do I use them?
Identification of Core Design Patterns – Design Pattern Definition: design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. – In short, design patterns provide a foundational blueprint for software development. – Patterns are NOT code, they are designs we apply to our application code.
Identification of Core Design Patterns – Core Patterns: • • MVC Design Pattern Singleton Pattern – Application. cfc Service Object Pattern Front Controller/ Command Patterns Business Delegate Pattern DAO/ Gateway Patterns Value/ Data Transfer Object Pattern
Identification of Core Design Patterns
Identification of Core Design Patterns – Model – View – Controller • Allows for a clear separation between User Interface Objects and the underlying data model • Elements of MVC include – Model, which manages data elements and responds to queries about its state and to instructions to change its state – View, which manages a rectangular area of the display and is responsible for presenting the data – Controller, which handles events from the user and system that affect the model and view • These application components allow the separation of the following – User interaction – Modeling of the external world (data) – Visual feedback to the user
Identification of Core Design Patterns – Singleton Design Pattern – Used to restrict the instantiation of a class to a single instance. – Application. cfc - On. Application. Start
Identification of Core Design Patterns – Service Objects • Allows Encapsulation of Business Logic in a single service interface. • Login. Service. cfc • Email. Service. cfc • Zip. Validation. Service. cfc
Identification of Core Design Patterns – Front Controller/ Command Patterns • The Front Controller is a single component created to handle all system requests. • Controls and coordinates processing of each user across multiple requests. • Employs Command (workers) in order to carry out requests. • Commands can be reused throughout the application across multiple Views
Identification of Core Design Patterns – Business Delegate Pattern • A simple class that acts to create separation between the Presentation/ Web tier client (HTML/ RIA) and the business tier on the back-end. • Provides remote access from Web clients to important business tier services.
Identification of Core Design Patterns – DAO/ Gateway Patterns • DAO – Data Access Object – Provides CRUD operation methods for specific business objects. • Table Data Gateway (Fowler) – Provides a similar set of data access methods. Commonly used in Cold. Fusion applications for bulk data access. (i. e. queries that return large data sets)
Identification of Core Design Patterns – Data Transfer / Value Objects • Also called “beans”, this pattern provides a way to transfer data back and forth to the Web Client tier • Value Objects are NOT packaged exactly like Database tabels • Designed using a UML Class diagram
Frameworks Various Frameworks implement design patterns: Cold. Fusion • • Cold. Box Mach-II Model-Glue Cold. Spring Flex • • • Pure MVC Cairngorm Model-Glue Swiz Mate
Shut up and show me some code!!! When building an application, where do you start? – View Controller Model? – Model Controller View – You have a database – Where do I go from here!? – Let’s check out a real scenario!
Questions? Dan Blackman Mudd Brick Inc. Dallas, TX dblackman@muddbrick. com
- Slides: 26