Amazon.com Widgets

CFObjective: Day 3 - Top Secret Scorpio

Ben Forta

Scorpio focus: Developer Productivity, Integration, Management & Admin
New features have relation to Eclipse in some way
AJAX Support

  • Controls - cfgrid, autosuggest, etc.
  • Layout
  • Wizards - ColdFusion/AJAX Application Wizard - Kick start for AJAX apps
Eclipse-based ColdFusion Debugger
  • Step through debugging
  • Access to variables
  • Breakpoints
This debugger is pretty cool.  Eclipse connects directly to your server and waits for messages from ColdFusion.  As you browse, Eclipse will update automatically.  Within Eclipse you can step through line by line and see real-time variable status.  This is yet another very strong reason for all of us to start using CFEclipse within an appropriate development environment!

Flex Data Services enhancements
  • Integrated directly into ColdFusion, even given the option to install during CF8 installation.
  • FDSE is free for 1 CPU.

  

CFObjective: Day 3 - SOA with ColdSpring and Trans

Sean Corfield

Service-Oriented Architecture - Expose common business entities and operations to multiple clients across the enterprise.
Adobe Hosted Services "Stanza" project

These concepts might be quite useful for our "bird" project.

SOA

  • Data Dictionary - Everyone needs to agree what a "customer" is.
  • Service Directory - You need to be able to find your services.
  • SaaS - Software as a Service - Any form of offering that is typically a desktop app, now on the web.
    • 20% growth in SaaS as opposed to 6% for normal desktop software
    • Often exposes an API for 3rd party apps
  • SOA
    • A way to structure and build systems that naturally exposes those APIs
    • Building blocks for your software
    • Building blocks for 3rd party software
    • Like regular apps, but with a few layers
      • Sounds like MVC apps
      • Different because the System layer calls out to remote services perhaps on different servers
CF is a great choice for SOA - as producer and consumer of services
Web Services
  • SOAP
  • REST
  • JSON (native in CF8)
Flex and Flash Remoting

How is SOA different?
  • Client-Server by definition
  • Clients are varied and can be dumb - don't need to know about your services
  • Auth and sessions
    • Remote clients have no sense of session
    • Can't use session/client scope
      • Turn off session scope to save memory
    • app and server scopes are okay
    • Solution is to pass tokens around
      • Store tokens in DB
      • Schedule task to clean old tokens
  • Data Formats
    • Simple XML is probably best
    • JSON
  • Published API definitions
  • Error Handling
I will gladly admit that the rest of this presentation went rocketing over my head.  I think it actually made it into orbit.

 

CFObjective: Day 3 - Scorpiro 1337 r0x0r!

Jason Delmore

Scorpio features only a geek would love. 
* Some of this stuff may or may not make it into the product.

  • JavaScript Operators - very cool - !=, <, >, ++, ==, etc.
    • I've been wanting "++" and"!=" since the very beginning!
  • Implicit array and struct creation - excellent!
    • <cfset myArray=["Steve","Tim","John">
    • <cfset myStruct={product="ColdFusion",version="8"}>
  • Argument Collections
    • <cfset args=StructNew()>
    • <cfset args.name="myQuery">
    • <cfquery argumentscollection="#args#">...</cfquery>
  • <cfthread>
    • Run, Join, Sleep, Terminate
    • I sort of feel sorry for anyone who bought Blue Dragon for the threading
  • New functions to simplify i/o operations
    • FileClose(), FileCopy() FileDete(),FileOpen(), etc.
    • Can use <cfloop> to incrementally loop through file lines
  • <cfAjaxProxy> - includes all Javascript plumbing
    • Allows Javascript to call methods within CFCs
    • Returns values of CFC methods can be in standard AJAX formats
    • example - Can use Google Web Toolkit in front of CF
    • This could be very powerful
  • Drill into details with client-side binding
  • Additional AJAX functions
    • ColdFusion.getElementValue
    • ColdFusion.navigate
    • ColdFusion.setGlobalErrorHandler
    • ColdFusion.Ajax.submitForm
    • ColdFusion.Grid.getGridObject
    • ColdFusion.LayoutExpandArea
    • ColdFusion.Window.create
    • ColdFusion.Window.hide
    • ColdFusion.Log.dump
    • ...and MANY more
  • Image Manipulation with about 60 related functions!
    • ImageAddBorder
    • ImageBlur
    • ImagePaste
    • ImageRotate
    • ImageResize - can specify details such as interpolation method!
    • IsImage
    • ImageSharpen
    • ImageSetAntialiasing
    • ImageRead - to read in an image - you can then dump it's attributes
    • ImageWrite - to write back image after modification
    • getReadableImageFormats() - Will provide of list of image types able to modify on a given platform
    • ...and MANY more!
  •  CFC Interfaces
    • <cfinterface extends="someInterface" hint="some hint" displyName="SomeInterface">
  • getComponentMetaData(path)
  • Role based security in CFAdmin - Very nicely done
    • User manager is part of the API as everything else
  • Stored Procedures now support caching
  • Query caching now works when using <cfqueryparam>!
    • We must ALWAYS use <cfqueryparam>
  • <cfftp> now supports Secure FTP
  • CFC Serialization - allows for J2EE Session replication
  • Flash Forms restrictions have been removed for full ActionScripting

Questions:
So the CF Ajax tags do anything with Spry?  No!  They all use Yahoo UI.
 

CFObjective: Day 2 - Sustainable Apps with Framewo

Matt Woodward

Overview of building sustainable apps using Frameworks.  Focusing on Mach II, but applicable to all frameworks.
Kevin Tate - "Sustainable Software Development" - Good book to check out.


Technical Debt - builds up over time, gets worse as more changes are made.  Extremely hard to pay back.


Keys to Sustainable Dev

  • Working product at all times - daily builds, small chunks
  • End user is always involved
  • Test driven development
  • Uncompromising standards for code quality - I agree!!
  • Avoid over designing app - only build what is needed
  • Okay to abandon pieces that aren't working
Principles and Practices
  • FLiP
  • UI Prototypes and user involvement - Getting Real
  • Code for platform independence - meaning don't hard code file system paths (use CF path functions), be strict on case and naming.  What if we switch to Linux?
Frameworks will sort of force you into OO and MVC.
XML config file in frameworks provides you with a roadmap of the app.  New devs can quickly see what the app does.

 

CFObjective: Day 2 - Scorpio Server Monitoring

Adam Wayne Lehman (not Jason Delmore)

Overview of Server Monitoring and Performance.

Wow!  Just tons of great features.  Not much to say here other than the tool gives you everything you could want.  This kind of tool has been missing from CF from day one.

Can see actual, individual sessions
Can abort processes manually (if they are growing and not ending)
Can see all variables being generated
Can see complete memory usage and what it consists of
Can call Garbage Collection manually at any time!

Requests by Memory Usage gives you a great idea of capacity.  Can see how much memory (on average) a request requires.  Simple math will tell you about how many requests your server can handle at a given moment.

Database monitoring will be incredibly useful.  Will show queries as they run, how much memory they need, and their average run time.

Neat!  Can define many different kinds of Alerts that will fire if certain things happen on your server.  The Alert won't just email a person, but also automatically (if you desire):

  • Create a snapshot of the current server environment and dump to a text file
  • Kill all threads running more than 60 seconds
  • Reject any new requests
  • Run a custom Alert CFC will all kinds of custom logic!  So you can really make Alerts do anything you desire.
  • JVM Alert: Can automatically perform garbage collection at a certain threshold.  (This should really help us at work!)
There is a bit of a drawback.  Just like debugging, when server monitoring is up and running, there is about a 15% overhead on your server.  However, there is an alternate view called Multi-Server monitoring that looks at all running servers in a very low level fashion.  Then, if needed, you can drill in.


 

CFObjective: Day 2 - OO Architecture Back to Front

Matt Woodward - (coldfusionweekly.com)

Providing a practical example of real world ColdFusion object-oriented application architecture.

Interesting - Most devs think that the DB is the most important part of the app.  But if we had servers with unlimited RAM and never crashed, a DB wouldn't be needed.  The Object Model is the most important part of the app.

Keep objects doing one thing only, and create them such that they don't know anything about other objects.

App Layers:

  • Biz Logic Layer - most important
    • Create an API to talk to this layer
    • Database tables and fields do not map directly to your objects
  • Service Layer
  • Controller Layer
  • Presentation
Simple Object: Person (as a bean) - dumb object with attributes and behavior - relates only to a singe record in the DB.
Getting data from a DAO - grabs single records from the DB into a bean.
  • Request for person data to controller
  • controller talks to service layer
  • which talks to DAO
Gateway objects grab multiple records - usually returns a query object - could also return a collection of beans, but not recommended.  Better just to use a query.

Service Layer provides an API to the entire biz layer.  Key in making biz logic resuable.
Controller layer - can be a framework or not.  Should be as dumb as possible.  Just talks to Service layer.
Pres layer - should only contain pres logic.  No data logic.

Sample App: Contact Manager - Very simple app with all 4 layers.  Try to obtain this sample code.

My comments: 
This app seems like a perfect example of OO over engineering.   Matt kept saying that it's important to do all this in order to allow your biz logic to be used in other apps.  But how often does that ever happen?  Seems like if your app ever changed (say you needed to add 3 more fields to your Person table), you would need to make tons of changes in every single layer across 6 templates.  You would have to edit nearly all of your methods.  His tiny app uses about 500 lines of code.  I know it's just a sample app, but you could build it in about 1 hour using two pages.  And if I ever "needed to build this app again", I could copy and paste my original code in about 20 seconds. 

I realize I'm not being fair.  Don't yell at me.  This is the technique we will need to use in building our new, top secret app at work.  Our app is going to be quite large and will rely heavily on passing objects around to various sub-applications that make up the meta app.  And we will need to have the ability to create and attach additional apps at any time in the future.  The LAST thing we want to do is fill the thing with procedural code.


 

CFObjective: Day 1 - AJAX with Scorpio

Sean Corfield

Over 100 AJAX libraries are out there.  (Really?)  That's hard to believe.
AJAX and Scorpio

  • Provides a rich set of UI controls
  • Enable rich input/output
  • Provide natural way to handle data management
New tags for layout and controls
CFC results can be returned in JSON format
Ability to bind data and methods to controls
Automatically proxy CFCs in JavaScript
Scorpio AJAX UI controls are based on Yahoo UI toolkit and Ext JS library

Input and Output
  • Data binding across controls
  • rich textarea (instead of FCK!!!!)
  • Built-in autosuggest
  • <cfgrid> and <cftree> get reborn
Databinding
  • bind= attribute for cfgrid, cfinput, cfselect, etc.
  • bind="{city}, {stateCode}"
  • bind="cfc:path.to.cfc.func(args)"
  • bind="javascript:func(args)"
  • etc.
Data binding example: related select
Wow!  Done in 13 lines of code, and 1 basic CFC to grab data - 1 tiny JS (mostly to handle errors) function and data binding to <cfselect> - Very cool

Rich text editor - Uses FCKEditor!!!!!  Hah!  I was right in backing FCKEditor all this time.

Auto-suggest: example
Very cool.  Dynamic related auto-suggest.

At this point, someone asked to view source on the page Sean was demoing.  Yikes!  It was pulling every single library from the YahooUI into the page!  Then, someone in the audience piped up and noted that the beta release always uses the entire Yahoo UI library, but the release version will contain a mechanism that auto-selects only the needed libraries!  Sweet!  This is exactly was MS was demonstrating with their AJAX implementation in ASP.

<cfgrid> now rocks with AJAX data binding.  This can be VERY useful.

<cftree> now rocks by dynamically fetching data upon expansion - though I'm still not sure I would use <cftree> in a front-facing app.  Seems like it would be great though, for admin types of apps.  Trees can be cached.  Someone asked if you could drag and drop between tree items.  The answer is that Yahoo UI can be extended simply by grabbing code that others have already done (and they *have* done the drag and drop thing) and just drop it into your app.

NOTE: Try to acquire Sean's example code.  This could be very useful in getting a jump start in using Scorpio AJAX.

example: AJAX login window!  Very cool.

<cfajaxproxy cfc="ajax.AuthenticationSystem />
Allows javascript code to access CFCs directly.

Built-in AJAX debugger!  Can dump objects.

AJAX UI Controls in Scorpio - small example
  • cflayout
    • creates tab layouts, horizontal and vertical
    • Individual tabs can be closed (hidden)
    • border layout
    • cflayoutarea to populate small bits of content - overflow can be specified and handled
    • example: tabbing - VERY simply and cool
    • example: panels and accordion controls - not much code needed at all - can specify things like min and max sizes.  Neat!
  • cfmenu
    • Sean had a tiny JS function that did auto-breadcrumbing.  Look this up.
  • cftoolip
    • Fantastic!  I've been using tooltips more and more in various ways
    • Extremely flexible
    • Can include an entire HTML page!
  • cfwindow
    • Holy crap this would make my life easier!
    • Creates modal windows and any other kind you need
    • Content can be anything.
    • NOW the true power of CF is revealed!!!
    • I am very excited about this
  • cfdiv
    • Creates an HTML tag whose contents are populated from a dynamic URL - Sounds interesting!
    • auto-generates a "Loading..." message with animated icon.
  • cfpod
    • Holy crap.  Very awesome.
    • Used blog pods as an example.
    • Virtually the same as cfdiv, example has title.  cfpod is more specific for it's intended usage.
SerializeJSON(), DeserializeJSON(), IsJSON()
AJAX Date Picker

http://corfield.org

Where does this leave Spry?  In my opinion... high and dry.  I really don't know why I need it.
My prediction: ColdFusion 9 will ditch Yahoo UI in favor of a finished Spry product only because it seems ike a hack to rely on Yahoo UI.  I don't agree with this, but it's my prediction.  Ultimately that seems like a lot of work for nothing, unless Spry somehow turns out to do things better or more efficiently than Yahoo UI.

 

CFObjective: Day 1 - Object Oriented Modeling

Hal Helms

Ontology - ask things like "what does it mean to be a customer?"  Beware of an unrelated collection of functions masquerading as a component.
Big mistake is thinking about "attributes" of an object rather than it's "responsibility"!  What responsibilities does a customer have?  What do they need to do that a normal person doesn't do?

Different tiers for different purposes: Bullseye

  • Data in the middle, then Domain Model, Services, App controllers.
  • Domain model should get the most thought.  "In our view, this is how we define the world."  Business logic.  What are the objects within your domain?  This is excellent for Phoenix.  Your domain model should be able to stretch across applications.  A "user" always acts like a user across apps.  A "goal" is always a goal.
  • Services simply provide services to your Objects.  A user needs a login service.
Problems - Anemic domain model
  • If behavior is inherited in the domain's understanding of itself, a domain model component is usually a good choice.
  • If behavior is specific to a particular app, a service layer component is usually a good choice.
Domain Model
  • An abstraction of the domain (business logic) in which the domain is accurately reflected through it's objects.
  • Abstract Data Types - idealizes real world components
  • Interesting example - Bob borrows money from Linda
    • "How much does Bob owe Linda?" - Where would you place this function, in Bob or Linda?
    • Everyone said Linda, but Bob is the real answer.
    • In the real world, Linda is the choice because it's safe, but in OO, there is no danger and it makes far more sense to place it in Bob.
    • Nobody knows better how much money Bob owes... than Bob.
    • What if you needed a function where Bob wants to pay back a certain amount of his debt?  He needs the total owed value.  Why should he have to get that from Linda?
    • Linda would contain functions to loop over borrowers and ask each... how much do you owe me?
UML - Class diagrams
  • Class name
  • Properties/Attributes
  • Responsibilities/Methods/Behaviors
  • Avoid going crazy with adding properties as you probably don't need them.
Classes should work together through a stable API rather than through detailed knowledge of the internals of that class. (low coupling)

Another interesting example - creating classes for a company - Employees where some are hourly and some are salaried.
Everyone would be tempted to use inheritance:
  • Employee object
    • HourlyEmployee extends from Employee
    • SalaryEmployee extends from Employee
This is wrong.  What happens if an Employee changes from Salary to Commission?  What if you hire Temps?  etc.
Much better to use a design pattern called "Strategy".  Payroll or Compensation becomes it's own object.
This another example of "Composition over Inheritance".


CFObjective: Day 1 - Object Oriented ColdFusion

Nicholas Tunney - AboutWeb - Object Orientation for ColdFusion

I figured I needed an overview of OO in CF in a practical sense, so I checked out this session.

Basic OO overview - standard stuff
The class is the core of OO - properties, constructors, accessors, object methods, sometimes CRUD.
An object is an instantiated class. 
Think like the object.  (Simon's ObjectThink)

  • Who can I talk do?
  • Who do I depend on?
  • What can I do?
Encapsulation - Black boxing
  • Private properties
  • Accessors/Mutators - Getters and Setters - Developers don't just access structure.color, they getColor() instead.
  • Watch out for over engineering - Very easy to do
Polymorphism - one class, many instantiations
Example: Employee Class
  • Manager
  • Accountant
  • Programmer
Inheritance and Composition - The "is a" "has a" paradigm
  • Employee
    • Employee has an email address
    • Manager is an employee
  • "Favor Composition" - always think of composition first
Practical application in ColdFusion

Most people just use CFCs as "query containers".  That's okay, but you are missing out on more power.
Email Nicholas for a library of CFEclipse snippets!

Creating a class - Constructor
<cffunction name=init" access="public" returntype="Employee" output="false">
    <cfreturn this />
</cffunction>
creating a public function places varaiables into the variable scope and then this scope.

Creating a class - Accessor (Getter)
<cffunction name="getID" access="public" returntype="numeric" output="false">
...calculations...
<cfreturn variables.id />
</cffunction>

Creating a class - Mutator (setter)
<cffunction name="setID" access="public" returntype="void" output="false">
<cfargument name="id" require" true" type="numeric">
...calc...
<cfset variabes.id = arguments.id />
</cffunction>

Creating a class - public and private methods - what other methods need to be in the object?
  • DAO - CRUD
  • The "what can I do" of the object
Instantiating an object - best practices

<cfset myObject="createObject("component", path_to_cfc).init() />
example:
<cfset Carl="createObject("component", "cfc.Employee").init(1, "Carl") />

Interacting with Properties
  • Properties are in private scope (encapsulation
<cfset Carl.setFirstName("Carl") />
<cfset firstName = Carl.getFirstName() />

Persistance Methods - CRUD - can pull them out into other objects, but no problem to just stick them in your main object.  Can be further encapsulated using a commit() method.  The object can be set to "figure it out" when a dev calls the commit method.  ie, update if already exists, add if doesn't exist.

Gateway Objects - singleton object instantiated once per app.
  • Used for accessing multiple objects or records
  • For small apps, methods can be put into one main data access object
  • for large apps, best practice is to move methods into object specific gateways
example: list and output all employees.  Does it need to be it's own object?  Or loop over objects?  No, just stick query in Gateway object and call that one method to get your list.

Nick's sites

nictunney.com
cfoop.org

TIP!
Use Poseidon for UML and diagramming.  It may also have ColdFusion hooks.  Nick also absolutely loves Model-Glue.  It will "get out of your way" when you need to.  Nick loves this feature!  Sounds like I would love it too.  You don't ALWAYS needs to live strictly within the OO, MVC structure.

Migrating a site:  Look at existing messy app.  Create a Model-Glue directory structure off to the side.  Attack the app in small chunks and modularize everything logically.


 

CFObjective: Day 1 - Keynote

Jason Delorme: Adobe - Keynote Scorpio Highlights

Very freakin excited about ColdFusion 8 AJAX support.  Jason indicates that Scorpio "leverages best of breed AJAX libraries", ie, Yahoo UI.  You can also use Spry, but Yahoo UI will be the library for Scorpio.  Also very interested in AJAX data binding in Scorpio.  It took 20 lines of code to link a nice looking, fully functional AJAX datagrid in a normal CF page.  It was super fast.

Wow!  ColdFusion 8 is 4 to 5 times faster than CF 7!  CF 8 now has <cfthread> support.

The image processing is incredibly fast.  Faster than anything I've seen before.  The image support doesn't just hook into some backend DLL or anything, it doesn't launch any backgground processes or anything.  It's all native and extremely fast!  I love when you can ditch "support" software, and it looks like CF 8 will allow us to ditch a lot of things that we typically install and run to enhance ColdFusion.  We can get rid of Lyla captcha, ImageMagik, AJAX libraries.

The Enterprise license will cover server virtualization.  Therefore, it doesn't cost anything extra to run multiple "copies" of CF Enterprise on infinite virtual servers.

There is no release date.  Mid 2007 is all we get.


Raymond Camden's BlogCFC version 5.8.001