Skip to content

#cfunited Notes – “Extending CFBuilder w/ CFML”

http://labs.adobe.com/technologies/coldfusion9/

What can extensions do?
Anything CF can!
•    written w/ CFML and XML
•    runs on a CF server
Common Uses
•    code generation
•    framework scaffolding
•    server management / probes
•    code analysis
•    reporting
Add New Context Menus
•    RDS View (databasees and tables)
•    Outline View
•    Resource View (projects and files)
Workspace Events
Installing a CFBuilder Extension
Preferences -> CF -> Extensions
Good practice to put extensions folder under CFIDE so they are separate from applications

ide_config.xml

  • application details
  • extensions are a simple zip archive
  • optional collection of data during install
  • responding to workspace events – onProjectCreate
  • adding context menus
  • filter with regEx to optionally appear

Collecting User Input
static input w/ native eclipse controls
types

  • string
  • dir
  • boolean
  • file
  • password
  • list

attributes

  • name
  • label
  • tooltip
  • required
  • default
  • checked
  • pattern
  • errorMessage
  • helpMessage

keywords for default values
{$projectLocation}

  • projectLocation
  • projectName
  • serverHome
  • wwwroot

Handler Communication

  • sends info via XML

Dynamic Input

  • XML, HTML, AJAX, Flex, Eclipse SWT
  • showResponse=”yes”
  • response can be HTML or XML

Tips

  • You can reload from prefs if you make changes to the xml
  • Errors output to Eclipse logs (windows > show view > other > general > error log)
  • You can also write your own log with cfLog
  • Use CF to generate CF (use generated code as <:cf and rip out the :’s later)
  • Adam’s Ext-Util.cfc

#cfunited Notes – “Facebook applications with a CF Backend”

Workings of a Facebook App

  • Facebook -> your website -> Facebook API -> your website -> Facebook
  • They scan for “bad” stuff before displaying it.
  • Good though because its all secure for you.

Setup

  1. name your application (read the terms – good bathroom reading)
  2. make note of your API key and secret (needed for all API calls)
  3. setup a facebook URL (unique) and the callback URL (your server and should be directory only as they will append different files)
  4. settings page to set sandbox, app type, sms integration and iphone

1st Roadblock

  • validation is carried out on form fields that have specified names (pre cf9)
  • fb_sig is in the wrong format and will never validate. set to another field and clear that field.

A Look at FBML

  • tag system that handles output of data
  • tags display data just as the website does
  • tags are mostly used for UI/layout
  • conditional logic tags do exist (if/else)

Digging into the API

  • RESTful-ish API
  • dot delimited methods
  • methods are grouped in actions
  • returns XML/JSON/PHP
  • access to FQL (SQL-like)
  • API Key, Call Id, MD5 Hash of secret and Version needed on EVERY request

CF is your glue

  • Use API to get data
  • parse and loop over data with CF
  • output using FBML
  • store data associated with uid w/ CF + SQL
  • do not use cfLocation but rather fb:redirect and you can only redirect to FB

? Can you limit who can add your applciation by FB network?

After they allow it, you would have access to all that information. If they are not in the network that you wanted then you could just show a denied message or there may be API functionality to kick them oput of the application.

simonfree.com/presentations

twitter.com/simonfree

#cfunited Notes – “CF Developer’s Guide to Mate Flex Framework”

Sample Application

Uses upcoming.org REST API to show events

ColdFusion End

  • basic CFC to call API (getCountryList, getStateList, getEvent, search, etc)

Mate

  • easily handle flex events
  • tag-based
  • dependency injection
  • supports modules
  • flex messaging support
  • extensible (extensions available)

Typical Process

  • view — event –> main.mxml -> eventMap (remote objects to CF) -> manager
  • result is then injected into the view

Terminology

EventMap:

  • EventHandlers
  • RemoteObjectInvoker
  • ResultHandlers
  • MethodInvoker
  • EventAnnouncer
  • Injectors

Manager

Setting up your Flex App

  • Enable CF remoting
  • Include mate.swc
  • Typical folder structure

Mate does not care about how you build your view

  • follow standard flex practices
  • no framework references in the view (exception being dispatcher which does “private” events but this shouldn’t be used unless needed)

Events are Events

  • just regular events
  • dispatched using standard dispatchEvent() method
  • “bubbles = true” will be helpful

EventMap handles Mapping Events

EventHandlers define

  • what the event responds to

Confronting your manager

  • business & app logic
  • bindable properties

Injecting Data

  • keep view independent of framework
  • view has a setter method to update it when event happens
  • injectors are defined with target and then data to pass (propertyInjector, listenerInjector).

Responding to event in the view

- cut off -

References

#cfunited Notes – “CF & PDF: Improving Your Workflow”

What’s the problem?

Normally, lots of steps in the process involving lots of different people at different levels.

What’s the solution?

After noticing the problem for some time, most organizations will finally address the problem.

CF + PDF!

Accelerates form creation that has server side connections.

Tools

  • LiveCycle Designer – Windows only!?!?!? Comes free with Acrobat Professional.
  • ColdFusion

Demos

  • Loads in browser (machine dependent) and URL still says .cfm
  • Forms have a JS backend to add some functionality like calculations/move text around/etc.
  • CF9 adds package functionality to add multiple files together in one .cfm load

#cfunited Notes – “Code Reviews and Team Dynamics”

What is code quality?

Not talking about the little things like “you missed a cfQueryParam there” but more “is it going to stand up to the test of time” so that things last.

Steve McConnell

1 of 3 most influential people in the software industry (Bill Gates and Linus Torvald as the other two)

“Testing does not along make better software.”

“If you want to lose weight, do not buy a new scale; change your diet. If you want to make better products, do not test more; code better.”

Improving Code Quality

  • code standards guidelines (note: guidelines was spelled wrong on the slide)
  • pair coding
  • user groups
  • test driven development

Code (Peer) Reviews

Peer in the sense that we are not reviewing who wrote the code but more working as a group of peers to make the code better. Its easy to make it personal but you need to make sure that is left out. Don’t say things like “why did you do it this way?” but rather “I don’t understand this section.”

Key: Don’t use “you” statements.

Goal?

Understanding the goal will help get to the finish line.

  • drive quality (obvious goal)
  • build a team (important but hard)
  • increase fungibility (ability to cross training)

Self Review

Have something to talk to. Actually speaking out loud helps immensely because your brain processes things differently when it hears it than when you just think to yourself. Who/what you are talking to does not matter.

Informal Peer Reviews

  • design validation
  • agile side of desk
  • talking out loud
  • “manage up”

One method is to initiate on your own code. “Hey Erin, would you take a look at some of this code?” She can find mistakes but also learns how to do some things.

Another way is to walk over and ask what another developer is working on. This gives you the opportunity to get out and talk to someone which helps build a team but also to learn/teach something in both directions.

Building team dynamics should also be part of your job description.

What about the un-passionate types? They are normally the people that just want to get things done and don’t care about the quality. This is quite hard.

Rules:

  • Everyone learns differently (be inviting to other styles of learning)
  • Create comfortable communication
  • Follow through (everything else ONLY works if you do this)

Formal Peer Reviews

  • review code ahead of time
  • don’t spend more than 90 minutes
  • meetings should be a recap
  • tools help

You do not want this http://www.frequency-decoder.com/2009/05/29/wtf-s-minute but rather a collaborative effort to make the code better. You want a to do list in order to make the code production ready. You do not want the experience to get personal towards the coder at all. The leader is in charge of making this is not done. Side conversations can happen if needed because if you reprimand someone in front of the group, you are making it personal as well.

? don’t defend your own code during the meeting.

Code Review Tools

  • Crucible by Atlassian. <$5000. has very good version control integration.
  • Code Collaborator by SmartBear. $1299/concurrent user w/ 10 user minimum

But really you don’t need a tool, if you have some sort of version control and eclipse then you have all you need.

Key: Don’t dredge up the past!

Full slides at Adam’s blog http://cfrant.blogspot.com/

#cfunited Notes – “CF9 and AIR: Developing Offline Applications”

The same 3 ways (WebService, HTTPService and RemoteObject) to connect to CF from AIR that existed in CF8 will continue in 9.

New things in Centaur

Fast Remoting

  • made several times faster
  • direct data translation between ActionScript and CF types
  • circular ref bug is fixed
  • no code changes required
  • support the old style remoting for backwards compatibility

ActionSript proxies to access CF tags

  • access CF tags from within MXML
  • chart, image, document, mail, pdf, pop
  • no server code (cfm/cfc) required
  • enable access to services in CFAdmin (username/IP)
  • include “services.swc” in AIR app
  • use <cf:Config…> to connect to the server

? offline access to proxy?

No the processing engine is the CF server so this part will not work offline.

Built-in online support

  • build offline apps without SQL mess and conflict handling
  • CF-AIR persistent framework for SQLite DB on client side
  • CF keeps track of all updates to local DB and syncs the server
  • session.commit() will send all changes that have happened in the session since the last commit
  • conflict handling is completely configurable based on operation (insert, update, delete). you get back the original object and the new object and can decide which should be saved where.

Other Enhancements

remotingFetch

  • cfProperty attribute
  • if false, the value is not send on the wire for flash remoting
  • true by default

resetTrackingChanges

  • resets all tracking data in CF offline store

ignoreLazyLoad

  • on commit, need entire tree

askjayvir.blogspot.com
rakshith.net

#cfunited Notes – “CF911: Tools and Techniques for CF Server Troubleshooting”

When the stuff hits the fan:

  • you want to know what went wrong and why
  • diagnostics to track errors and other info – in CF, web server, DB and whole OS.
  • available tools for monitoring CF – free/commercial/cf/generic
  • presentations at http://www.carehart.org/presentations

Typical Scenario

CF stops responding

What do you do?

  • Restart CF – doesn’t find root cause
  • Diagnostics logs – finding the right logs can be valuable
  • Monitoring tools – which ones? built in vs add on? check for running requests.
  • search google/mailing list/troubleshooting support

Free Tools

CFSTAT – reports high level measures. num of requests running, queued, avg req time, more. sadly not there in the multiserver mode. enabled on the CFAdmin on the Debug Output Settings page.

Gotcha Note: avg req time is only the last 2 requests averaged so that value is not fully reliable.

GetMetricData(“perf_monitor”) – returns same data as a CF structure.

JRun Metrics – enabled in 6 to add a line at regular intervals to track current state (threads, mem usage, j2ee sessions, more)

CF8 Server Monitor – only in Enterprise. Charlie has 4 part blog series (option to turn on url vars ie. fuseaction) on his website.

Admin API – same as monitor

Commercial Tools

FusionReactor and SeeFusion

Both work with 6, 7, 8, 9, OpenBD and Railo.

All three open the blackbox to see currently running requests, view past long running requests, see details of each query as well as stack trace.

Alerts can be setup for certain states to email notifications.

FusionReactor writes more logs that can be very valuable.

Full presentation at http://www.carehart.org/presentations/#cf911

#cfunited Notes – “Subversion for Smarties”

-late-

Changelists

  • added in 1.5 (currently at 1.64)
  • groups files for operations (commit and diff)
  • great for grouping files for bug fix

You should know about changelists

  • part of working copy, not repository
  • only works with files and not dirs
  • one changelist assignment per file (if you put a file in a list that was previously in another list, it will move)
  • changelists cleared at commit (option to keep)

SVN Properties

  • think “metadata” for each file
  • stored in .svn/props
  • checked into repo with file
  • keywords – used for keyword substitution but must be turned on. examples: Date, Rev, Author, HeadURL, Id (case sensitive)

? per file?

Automate Keyword Substitution

  • config file “miscellany” section
  • /%AppData%/Subversion/ (windows path)
  • applies to working copy, not repo.

Hooks

  • run a program at certain points in commit process
  • implemented as bat file in windows / shell script in *nix
  • live in repo and not working copy
  • examples by default found in “repo/hooks”
  • types: start-commit, pre-commit, post-commit, pre-revprop-change, post-revprop-change, pre-lock, post-lock, pre-unlock, post-unlock
  • you shouldn’t use the hook to change the file – this leads to working copies that don’t represent the repo.
  • tips: permissions, execute with an empty environment
  • uses: push code to staging server, email notifications, update issue management software

RIA Forge Projects

  • Rob Gonda’s Abstraction Layer
  • SVN Sync – web browser for repo
  • deployment builder – enterprise level deployment tool using cf/ant/svn
  • skweegee – does what trac does + more (formerly trac_fu)
  • svnauthz – manipulate authz files
  • svnutil – air app to remove .svn info

Resources

http://svnbook.red-bean.com

#cfunited Notes – “Digging Through the Flex Framework”

Important skill

Why?

  • Everything isn’t always out of the box
  • open source
  • times are rough (set yourself apart)

Real world examples

Tips

  • become familiar with class hierarchy
  • FB keyboard shortcuts
  • source location (including default CSS)
  • finding component that best fits needs
  • preserve compiler generated code

Class Hierarchy

  • important to know wehre you are so you know whats available
  • UIComponent is base case for all visual components
  • ref docs contain inheritance paths (docs are your best friend)

Keyboard Shortcuts

  • Quick class opener (cmd + shift + T) – opens window and filters list as your type in search
  • quick class property/method (control + O) – lists all methods and properties for current file. works well for large files like UIComponent which is 9300+ lines

Source Location

  • /{FlexBuilderInstall}/sdks/{version}/frameworks/projects/framework
  • defaults.css

Demos

TextHeader/LabelHeader

  • Extends Text & Label
  • Objective: add border support
  • Container supports bg and border styles but how? container base class and found the borderSkin style value

ResizableTextArea

  • “gripper” was keyword

Preserving Compiler Generated Code

  • not all functionality is hard coded in the source
  • some is wired in generated code – deferred instantiation (tab content aren’t rendered until clicked on) and effect triggers
  • -keep compiler switch in the project settings

Overall, a bit over my head but good preso. Javier really knows his stuff!

#cfunited Notes: “Practical Refactoring: Making Bad Code Good”

Walked in and heard: “if you get nothing else from this session. it should be USE VERSION CONTROL” Well then. Nice to hear it again.

CompareNoCase – leads to comparing two things. worse CF function ever. “if something is true, then its false. that will blow your mind.” :)

Breaking down if’s into multiple rather than large wrapped/nested blocks.

Add more comments. Not everyone else is going to fully understand what you are talking about. Made reference to the children’s game “Telephone” where you say a phrase and pass it on. Things get messed up when people don’t fully “hear” or in this case rather understand.

“less code is not always better code”

CFSwitch? yes that’s another way but normally save that for when I have more cases. There would only be 3 here.

Splitting complicated logic into multiple functions will create simplier code in the end. Reading through the main function will be much easier down the line even though the code is split into different parts/areas.

“sometimes I write the comments before I actually write the code” glad to hear that someone else also does this! :)

? – How do you not get distracted with little things instead of refactoring the logic?

“I have raging ADD so that is a problem” Try to make sure the changes that you are doing actually add value and are not just fixing things to be “your way” of doing things.

Splitting this logic into different functions also helps with debugging because you know where to look.

? How do you balance refactoring with adding new functionality?

You should actually have the time but you have to decide where you are spending your time. Making incremental changes will make changes down the line faster to implement so in the end it can actually end up being faster. If it took you 30 minutes to figure out and 30 minutes to edit, spending 15-30 minutes more to refactor and make your changes will make the next change to this area much less. The next developer could take 30 instead of 60+ and then what about the next developer.

I like the ideas but skeptical that managers will see the time use now even if there is time saved down the line. Crunch time normally means “little” extra time now and “lots” of extra time later. The real question is: do we ever go back? :(