I present Making Bad Code Good 2010 to The CFMeetup at Noon Today

If you can join the Online ColdFusion Meetup today (March 18th) at noon EST, we'll talk about code, code quality and show you some techniques to help you make bad code good.

This presentation picks up where my 2009 Making Bad Code Good presentation leaves off. Same great concept with all new code samples and techniques.

If you work on a legacy application, or on code built by lots of developers over the years, you likely laugh your way through this presentation. I promise to be thought provoking and challenge the way you write code. In this session, we'll look at lots of code samples and walk through making incremental changes to speed development, reduce errors and make life easier for everyone involved.

Ideas and concepts in this presentation will help you improve your existing applications and write more maintainable code.

Why you should submit beginner/intermediate sessions to NCDevCon

NCDevCon is a free two day conference on ColdFusion, Flash, Flex, AIR, HTML, Javascript and CSS. We've been building on the success of last year, and making bigger moves to grow the community. We are a victim of our own success.

What I mean by that is, we've taken some big strides to find developers who aren't typically at Adobe conferences. Last year we held a free ColdFusion training day and also a free Flex training day. These training sessions were well received by the audience and much good was done.

This year, the interest for these classes has already quadrupled. We have many more developers who have no exposure to either ColdFusion or Flex. As such, we'd like to ask the community for help.

Many of the speaker submissions for NCDevCon are advanced sessions. We want those sessions to be included in our conference. We also want some good beginner/intermediate content as well.

Of particular interest to us would be sessions that teach newcomers to ColdFusion, how to do common tasks with ColdFusion.

The format for these would be 2 hour hands-on blocks. You provide the content and a step by step process, and we'll provide Teachers Assistants to help you keep the class on track. We'll also take care of making sure the attendees have the right software installed.

This is a great way to help your fellow developers and future developers. We promise to give you the star treatment while you are with us!

Some examples of sessions we'd like to see are:

  • How to build a contact form
  • How to build a dynamic product list
  • Building a data driven JQuery widget with ColdFusion
  • Reusing layouts in ColdFusion
  • Whatever else you can think of

So, if you would like to take part in this unique opportunity, let us know. We thank you in advance for the consideration.

IgniteRaleigh2 Our talk on Health

IgniteRaleigh was a smash success! A big thanks to Our Hash Tag LLC and Phonebooth.com for putting on a well run, creative event. A big thanks to M.C. Zach Ward (@zachward) for his skill in creating a fun, positive mood and keeping it going all night. He's a true professional.

As some of you know, I was very pleased to be chosen out of the herd to present at IgniteRaleigh 2 on Why Your Health Is The Most Important Thing You'll Ignore All Day. Having watched a number of Ignite style talks before, I knew it would be challenging to stay on message and on timing. Not much room for creative expounding when the slides auto-advance, is there? I also knew the other speakers would set a high bar by being dynamic, funny, creative and inspirational.

As I was presenting, I missed a good bit of the show. I did catch a few of the sessions, though like:

  • Janet Kennedy (@jkennedy93), 5 Bucks is Change. Her presentation was inspirational, approachable and the presentation most likely to change my life in some way. Take a look at her website http://www.5bucksischange.com/ for more information. When the recording comes available, I'll post it here.
  • George Smart's (@georgesmartTMH) great presentation on Mayberry Modernism – Why the Triangle is America's Hotspot for Way Cool Houses. I enjoy modern architecture and had no idea there were 100 noteworthy houses in the area.
  • Jess Commins (@renewabelle) made saving money sexy with her talk on How to save $100+ with a DIY energy audit. Great use of imagery to hammer the point home.
  • Elizabeth Gardner (@WRALweathergal) spoke on A day in the life of a meteorologist who gets up at 3am. This behind the curtain look into her daily routine was funny and well delivered. I might have a new favorite weatherperson.

My tips for presenting at Ignite

  • Every second counts. Either you are making your point, or wasting time.
  • Plan Plenty of Preparation. A 5 minute talk about something you are passionate about, is 20 times harder to prepare for a 1 hour talk. I give lots of 1 hour talks and I definitely had to work more at crafting this short pointed message.
  • Pick good images for your slides. I had over 100, which was whittled down to 16.
  • Double up on a slide if it deserves more than 15 seconds.
  • You will be out of sync with your slides at some point. No one will care.
  • Make recordings of your talk and listen to them for practice.
  • Put the best recording on an iPod and listen to it before your talk. It'll help you stay focused.
  • Love the crowd. The vibe at an Ignite is positive and supportive.

Special thanks go to:

  • My wife (@shannonscarlett) for helping me prepare
  • Jim Priest (@thecrumb) for adding a great deal of polish to my slides
  • Brian Erman for taping the event.

More Info

Here is a write up of IgniteRaleigh 2 by Indyblogs. Here is a Delicious page of book marks with blog recaps. Here are pictures from the event.

Watch My Presentation

Ignite: Dan Wilson from Brian Erman on Vimeo.

Get My Slide Deck

My slides are available on SlideSix, view Slide Deck for Why Your Health Is The Most Important Thing You Will Ignore All Day

Build Better Forms Even Faster

I've been a big fan of the CFUniform ColdFusion Form Library for a long time. Using it helps me build better applications quicker. Matt Quackenbush has just released a major update to the library with some really compelling features.

Firstly, CFUniform is much more Ajax capable and plays even nicer in your Ajax application.

Secondly, there are several new types, like CAPTCHA and Rating.

Thirdly, there is much improved support for global configuration.

All of this leads to a more flexible and powerful form library to power your forms.

Take a look at the CFUniform 4.0 Release Article and find out more details.

Why Your Health is the Most Important Thing You'll Ignore All Day

I've been selected to present at Ignite Raleigh 2 on Why Your Health is the Most Important Thing You'll Ignore All Day. I'm very excited to get to speak to this audience on such an important topic near to my heart.

Since launching ChallengeWave as a tool for businesses to help their employees start and stick with healthier activities, I've taken on the quest to raise health awareness and health happiness in people. Having the ability to share this with the fine audience at Ignite Raleigh 2, will be fun and exciting!

Ignite style presentations are fun, fast and informative for the audience. Speakers condense their topic into 5 minute presentation. During the presentation, 20 slides will be shown in a timed progression, 1 slide every 15 seconds. The audience gets to learn a lot about a lot of interesting topics in a short period of time.

Oh, and since the slides auto-change every 15 seconds, the speaker better keep up, or he'll be run over!

If you've not seen an Ignite style presentation before, check this one from last year's Ignite Raleigh by the master, Wayne Sutton:

New Northern Virginia ColdFusion User Group

A new ColdFusion User Group has started in Northern Virginia. Run by Denny Springle, this group will serve Northern Virginia's ColdFusion and Flex developers. The initial NVCFUG meeting, topic "CF Coding Standards, Code Refactoring and Code Re-Use", is tomorrow night, Feb 16th in Fairfax, VA.

So, if you are anywhere remotely close to Fairfax, please come out and support this new group!

Check out Meeting Information and NVCFUG information.

How to fix a corrupted Microsoft Office File

My wife creates massive proposals using Microsoft Word and Microsoft Office. Today she had a Word document spontaneously get corrupted and lose hours of her changes. The Microsoft Word document would not open at all, not on her computer, or any of her co-worker's computers.

I offered to take a look at the document and see if I could recover any part. She sent me the document and I started googling around for 'how to recover docx files and found a number of paid utilities claiming to fix the situation. Not ready to spend money, and on a whim, I tried to open the document with the Open Office, open source word processing software. Guess what, it worked!

The corrupted document opened just fine with Open Office. I easily saved the document as a .doc file which opened just fine on my wife's computer in Microsoft Office.

Since the file is now a .doc format and not a .docx format, some of the formatting was munged. However, fixing formatting is a whole lot easier than re-crafting pages and pages of text, don't you agree?

The best part about this, is it took less than a minute and $0 to repair the file.

Here are the steps:

[More]

So a CFML variable name cannot end with a "." character

I spent a good hour today trying to get some old code working and got stuck trying to fix:

a CFML variable name cannot end with a "." character

Can you spot the issue in the following code block?

view plain print about
1<cffunction name="doLog" output="false" access="public" returntype="any">
2    <cfset var emailData = {} />
3    <cfset emailData.EmailAddressTo = variables.instance.config.getScheduledTaskEmailAddress() />
4    <cfset emailData.EmailSubject = "From the Nag Email Scheduled Task" />
5    <cfset emailData. EmailContent = "#arrayToList( variables._base._log, '#chr(13)##chr(10)#' )#" />
6    <cfset variables.instance.emailService.sendEmail( argumentcollection:emailData ) />        
7    <cfset super.doLog() />
8</cffunction>

[More]

How to customize the ColdFusion AutoSuggest

ColdFusion 8 and 9 have an autosuggest functionality that just couldn't be simpler. If you want to have an autosuggest input on the screen, you can do it with a single line of code:

view plain print about
1<cfinput type="text" name="language" autosuggest="english,spanish,french">

That snippet will place an autosuggest box on the screen and allow a choice of english, spanish or french. Snazzy yeah?

If you want, you can bind the autosuggest to a javascript function, or directly to a CFC, making data retrieval and formatting very simple.

view plain print about
1<cfinput type="text" name="language" autosuggest="javascript:doSomethingJavascripty( {cfautosuggestvalue} )" />

view plain print about
1<cfinput type="text" name="language" autosuggest="cfc:DoSomething.coldFusiony( {cfautosuggestvalue} )" />

You can also make more complex examples, take a look at the ColdFusion 9 Documentation for Autosuggest for some ideas. All this is possible because ColdFusion used the extensive YUI library under the hood. The control used by the ColdFusion Autosuggest is the YUI AutoComplete widget.

Let's say you wanted to do something that the YUI AutoComplete offers, but isn't in the ColdFusion documentation, what do you do?

[More]

So You Want Cleaner Code? Nesting Conditionals and Booleans

This post continues the infrequent series on Clean Code examples. If you are enjoying this series, come to CFUnited 2010 and CF.Objective() 2010 to catch my presentation, Making Bad Code Good- Part 2, a live version of this series.

The main idea here is to provide practical examples of working code that can be written in a cleaner fashion. You may agree or disagree with what I've written, and I want to hear from you either way in the comments.

If you have a code sample you'd like to see refactored, send it to me through email (if you have my email already) or through the Contact Me form on this blog.

Code Sample

view plain print about
1<cffunction name="execute" access="public" output="false" returntype="boolean">
2    <cfargument name="attributes" required="true"/>
3    <cfset var local = structNew() />
4    <cfset local.customerGateway = createObject("component","model.customerGateway").init() />
5    <cfif structKeyExists( client, "customerID" ) AND val( client.customerID ) GT 0>
6        <cfif val( arguments.customerGW.getByID( val(client.customerID ) ).getChallengeQuestionID() ) GT 0>
7            <cfset local.result = "true" />
8        </cfif>
9    <cfelseif structKeyExists( arguments.attributes, "ChallengeAnswer") AND
10                structKeyExists( arguments.attributes, "ChallengeQuestionID") >

11        <cfif structKeyExists( arguments.attributes, "ChallengeQuestionID") AND val( attributes.ChallengeQuestionID ) GT 0>
12            <cfif structKeyExists( arguments.attributes, "ChallengeAnswer") AND len( trim( attributes.ChallengeAnswer ) ) GT 0>
13                <cfset local.cust =    arguments.customerGW.getById( client.customerID ) /> />

14                <cfset local.cust.setChallengeQuestionID( attributes.ChallengeQuestionID ) />
15                <cfset local.cust.setChallengeAnswer( attributes.ChallengeAnswer ) />
16                <cfset arguments.customerGW.save( cust ) />
17                <cfset local.result = "true" />
18            <cfelse>
19                <cfset local.result = "false" />
20                <cfset attributes.userMessage= "Please select a security question and provide an answer." />
21            </cfif>
22        </cfif>
23    <cfelse>    
24        <cfset local.result = "false" />
25    </cfif>        
26    <cfreturn local.result />
27</cffunction>

Read through the entire example and ask yourself the following questions:

  • What is the purpose of this code block? What are you using for your inferences?
  • Is it clear what this code is doing? Why or why not?
  • Can you spot the subtle bug in the code?

[More]