Transcript New Atlanta Communications, LLC
Introduction to Object oriented Programming for CFML Developers
Josh Adams
About Me
Josh Adams Email: [email protected]
Phone: (678) 256-5395 Developer Evangelist for BlueDragon at New Atlanta CFML Developer Past President of the Atlanta ColdFusion User Group, Inc.
Regular speaker at CFML conferences and at User Groups New Atlanta Confidential. | 1 © Copyright 1997-2007
Q&A Protocol
Please ask questions!
Feel free to ask questions at any time during the presentation Time permitting, we'll do Q&A at the end of the presentation I will address as many questions as possible Due to time constraints some questions may go unanswered today If I do not answer your question today, I will get back to you with an answer if you give me contact information New Atlanta Confidential. | 2 © Copyright 1997-2007
OO Background
OO (and OOP) = Object-oriented programming Motivation (a.k.a. why it exists, why it is used): provide flexibility and maintainability to code Ease of code reuse Ease and reliability of application modification through decreased code modification and instead increased code addition Guiding principle: code modularity Great…but my code isn't OO and it's pretty flexible, maintainable, and modular… New Atlanta Confidential. | 3 © Copyright 1997-2007
Functional/Procedural Programming
Let's start with what we know… Functional/procedural programming paradigm: collection of functions/procedures We don't have procedures per se in CFML but a function that returns no result is effectively a procedure Functions can be thought of as actors; they act on variables Functions do the work of the program Let's take a look at a simple example… New Atlanta Confidential. | 4 © Copyright 1997-2007
OO Programming
OO programming paradigm: collection of objects New Atlanta Confidential. | 5 © Copyright 1997-2007
An object is a thing More precisely, an object is a representation of a thing Has characteristics We call these "attributes" or "properties" Properties are just variables rebranded!
Those things which the thing has Has behaviors We call these "methods" Methods are just functions rebranded!
Those things which the thing does New Atlanta Confidential. | 6 © Copyright 1997-2007
Objects
Functions still do the work in OO!
But now they… …just know what they need to know!
…generally contain less code!
Methods
New Atlanta Confidential. | 7 © Copyright 1997-2007
Objects in CFML
A CFML object is an instance of a CFC An instance is a particular representation in memory New Atlanta Confidential. | 8 © Copyright 1997-2007
CFC Background
CFC = ColdFusion Component A text file with the extension cfc, the contents of which are CFML surrounded by
CFCs
The "building block" of OO CFML Blueprint for objects In the same way that a blueprint for a physical object defines what the object will look like and what it can do, a CFC defines what a virtual object "looks" like and what it can do Just as one blueprint can be used to create multiple physical objects, a CFC can be used to create multiple virtual objects CFCs are essentially the CFML equivalent of the classes found in many other OO languages New Atlanta Confidential. | 10 © Copyright 1997-2007
CFC Contents
Specification of the properties of objects that are created from the CFC Think of a CFC's properties as what objects created from the CFC have Definition of the methods of objects that are created from the CFC Think of a CFC's methods as what objects created from the CFC do Let's take a look at a simple example… New Atlanta Confidential. | 11 © Copyright 1997-2007
OO Concepts (Part 1)
Abstraction Grouping together in a CFC those properties and methods that define an object Encapsulation Information hiding Putting properties and methods in a CFC and exposing only those that need to be accessible outside the CFC and otherwise hiding all implementation details For simplicity, our CFC examples use the "this" scope, making all properties accessible externally to the CFC; in practice, properties are generally in the Variables scope and getter and setter methods are used to access them New Atlanta Confidential. | 12 © Copyright 1997-2007
The Power of OO
Code flexibility, maintainability, and modularity But how is that different from functional/procedural code?
New Atlanta Confidential. | 13 © Copyright 1997-2007
Functional/Procedural Code Maintenance
Let's look back at our simple functional/procedural example Before we had only one light source but now we want to add another… And then another… New Atlanta Confidential. | 14 © Copyright 1997-2007
OO Code Maintenance (Part 1)
Let's look back at our simple OO example Before we had only one light source but now we want to add another… New Atlanta Confidential. | 15 © Copyright 1997-2007
OO Code Maintenance (Part 2)
There has to be a better way!
There has to be a way we can reuse code efficiently There has to be a way we can associate similar/related objects New Atlanta Confidential. | 16 © Copyright 1997-2007
OO Concepts (Part 2)
Inheritance Derivation of CFCs from other CFCs; the derived CFCs inherit the properties and methods of the base CFCs These can be overridden, which means that they can be redefined in the derived CFCs Aids code reuse Keyword for inheritance in CFML: "extends" A CFC can only extend one other CFC Polymorphism Different objects having the same methods (which may do different things) which can be substituted for one another New Atlanta Confidential. | 17 © Copyright 1997-2007
Abstract CFCs
Can the base CFC merely define that a derived CFC should have particular methods and leave the details of the implementation of those methods up to those derived CFCs?
Yes—use an abstract CFC!
Cannot be instantiated directly Defined using
New Atlanta Confidential. | 18 © Copyright 1997-2007
Interfaces
But can I use multiple inheritance?
Yes—use an interface!
Cannot be instantiated directly Defined using
Objects validate as the type of any interface(s) they implement New Atlanta Confidential. | 19 © Copyright 1997-2007
OO Code Maintenance (Part 3)
Let's look back at our simple OO example Let's use an abstract CFC and then see how easy it is to add another light source… Then let's use an interface… New Atlanta Confidential. | 20 © Copyright 1997-2007
Introduction to New Atlanta:
We are Web Application Server Technology Experts
BlueDragon is our 3rd generation web-scripting technology
1.
FileMaker Web Companion (Lasso) 2.
3.
Web Publisher for FileMaker Pro databases Built in 1995, sold to Apple in 1997 Over 10 Million licenses since initial release ServletExec - Servlet/JSP Container First servlet engine on the market for Microsoft IIS and Netscape Enterprise Server with Servlet 1.0 Specification support Charter members of Servlet and JSP Expert Groups (Sun's JCP) Ten of thousands of licenses since 1997 BlueDragon CFML Runtime with native deployment and integration on J2EE and .NET platforms
New Atlanta has over 12,000 customers in 100+ countries
New Atlanta Confidential. | 21 © Copyright 1997-2007
New Atlanta Customers
Land's End
Over $1 billion in e-sales
MySpace.com
Over 110 million users ESRI – ArcIMS: web-based GIS ServletExec ships on ArcIMS CD
American Airlines
Worldwide reporting of safety incidents
Yahoo! Resumix
hotjobs.yahoo.com
New Atlanta Confidential. | 22 © Copyright 1997-2007
BlueDragon Editions
Standalone (including "Free version") BlueDragon Server & Server JX Native .NET
No need to write ASP.NET.
Direct .NET platform advantages within your CFML applications BlueDragon .NET
Native J2EE Any J2EE app server BlueDragon J2EE New Atlanta Confidential. | 23 © Copyright 1997-2007
BlueDragon Background
Oldest Java-based CFML application server 1998: created by a consultancy in Scotland 2002: purchased and productized by New Atlanta 2006: established a partnership with BEA through which BEA licenses BlueDragon from New Atlanta for sale as their own product Native .NET version: released in 2005 New Atlanta is a Microsoft Gold Certified Partner BlueDragon.NET is a Microsoft Certified Product (Windows 2003 Server) BlueDragon.NET is a .NET Connected product BlueDragon is a SQL Server 2005 Frontrunner New Atlanta Confidential. | 24 © Copyright 1997-2007
What BlueDragon Is & Does
CFML ≠ ColdFusion CFML is ColdFusion Markup Language CFML is code ColdFusion is Adobe's CFML application server ColdFusion is a software application Interprets CFML and generates output (HTML, PDF, etc.) You can deploy your CFML applications using ColdFusion BlueDragon is New Atlanta's CFML application server BlueDragon is a software application Interprets CFML and generates output (HTML, PDF, etc.) You can deploy your CFML applications using BlueDragon New Atlanta Confidential. | 25 © Copyright 1997-2007
BlueDragon 7.0
beta2 currently available Link on
New Atlanta home page
Feature complete: only bug fixes & performance tweaks anticipated prior to final release Release Candidate expected within at most a few weeks Final release expected several weeks thereafter
See the "What's New in BlueDragon 7.0" document on the New Atlanta website for full feature details
New Atlanta Confidential. | 26 © Copyright 1997-2007
BlueDragon Future
Expect another major release in second half 2007 Windows Vista and IIS 7 integration Microsoft ASP.NET AJAX integration Ajax-based Rich Internet Applications Image processing (CFIMAGE enhancements) Administration and configuration enhancements Other features from Scorpio (CFMX8) (?) Visual Studio plug-in (?) New Atlanta Confidential. | 27 © Copyright 1997-2007
Got questions? Ask away!
Q&A
New Atlanta Confidential. | 28 © Copyright 1997-2007
Let's give away some swag!
Swag Giveaway
New Atlanta Confidential. | 29 © Copyright 1997-2007
Josh Adams Email: [email protected]
Phone: (678) 256-5395
My Contact Info
New Atlanta Confidential. | 30 © Copyright 1997-2007