Archive for Coding

AIR: Why bother?

ColdFusion makes developing web applications insanely quick and easy. I don’t need to worry about the nuts and bolts of how to connect to a database, or how to invoke a web service, or how to read and write files on the server. I just write straightforward tags in my favorite text editor — and I’m done, web application launched for all the world to use.

But there are some things that web applications can’t do. They can’t really read and write files on the client machine. They can’t interact much with the client operating system. Drag and drop, PDF manipulation, copy and paste… the list goes on. And all that aside, an Internet application will never work without an Internet connection.

So how do you go about creating something that can do those things? A couple years ago, you were stuck building complex and clunky binary applications. So you have to dig into lower level languages like Java, C++, or any of the .Net languages.

Suddenly you’re working with compilers and writing 300 commands to do what one tag does in ColdFusion. Sure, you’re scoring points with the Java and .Net purists. But all that doesn’t leave a ton of time for the trivial things like the interface or user experience.

Enter the Adobe Integrated Runtime — AIR. You can use AIR to write a desktop application in Flex XML and ActionScript, or HTML and JavaScript. AIR exposes hooks in to the client system to handle a local database connection, catch drag and drop events, open up local files, and even render PDF documents.

So instead of writing complex machine code, you’re back to writing tags to define the interface. And you’re calling a simplified scripting API to do heavy lifting under the covers. And the API runs on both Windows and Mac, so your pool of potential users is not limited to one operating system.

Have you already written a full web application in Flex or AJAX? You’re only a few steps away from adapting the same code to run either online, or on the desktop. Maybe it’s a little of both.

Flickr has offered a pretty slick upload tool for a few years now. It’s an executable that you can install on your desktop to do drag and drop file uploads. Somebody at Flickr had to develop separate binary Windows and Mac executables.

With AIR, that’s something you could in one shot. Don’t believe me? Check out Matt Chotin’s MediaWiki uploader AIR app. They’re different underlying services, but it’s a great example of how a web app can be extended to the desktop.

AIR does a lot to bridge the gap between web and desktop apps. But just like ColdFusion did for web scripting, it makes building all the parts easy. And you get to use tools that you already know exactly how to use.

Now you can get back to focusing on what’s really important: building better software.

Comments (4)

Programming frameworks & rapid development

There’s an interesting discussion about programming frameworks going on over at the Wharton Computing developer blog: Why Not Frameworks?

Wharton Computing is where I work as a ColdFusion developer/administrator. There’s fifteen or so full time ColdFusion and Flex developers, and ten or fifteen more part-time developers scattered throughout the school.

It’s great to read what people think about the place of programming frameworks inside a school where the focus is on rapid and flexible development.

Comments (2)

Yet Another cf.Objective Wrap Up

I’ve got to echo the sentiments of everyone else: cf.Objective was a top notch conference.

I can’t think of a session that didn’t offer something new or challenging to think about. The smaller crowd allowed for some great interaction with community gurus and other developers. And the double-stuffed pillow topped beds, fresh carved pork lunches and artisan pastries were certainly nice touches too.

Overall, I came away with the challenge to improve my coding practices increase the planning that I put into projects.

At one point Terry and I were lobbying Mark Drew, lead developer of the CFEclipse project, to include more remote development features in CFEclipse. Remote development is how most of the developers in our shop work, but it definitely isn’t the industry standard.

Mark questioned why he should divert time away from other enhancements to build in support for bad practices. He used the analogy that if everyone had a six inch pointed spike fixed to their car’s steering wheel, we’d all be much better drivers.

Avoid cutting corners in any software development, plain and simple. There may not be a sharpened spike staring me in the face when I write code, but bad practices usually have a way of catching up.

I think it’s time to overcome my aversion to frameworks. I’ve always been worried about a hit to application performance and keeping up to date with framework code changes. But it’s becoming increasingly difficult to turn away from the industry tested patterns and practices that frameworks enforce. That’s not to mention all the repetitive busy work that frameworks automate so that I can focus on building better apps.

Comments (6)

Optional ColdFire Debugging

I’ve been using Ray Camden’s and Adam Podolnick’s ColdFire Firebug extension for a little while now. For those who haven’t tried it yet, the Firefox extension displays ColdFusion debugging info in a separate panel instead of appending it directly to the bottom of each page. It’s powerful stuff if you’ve ever had a page layout mangled by the vanilla debug dump.

Part of the setup for using ColdFire is deploying a customized debugging cfm template to your server. I never knew this — but ColdFusion actually uses a cfm template to parse and format the debugging output that ends up on each page. You can actually edit this file to customize the output on your system.

I wanted to get ColdFire working on our shared development server at work. But I knew not all of the developers would be on board to start. Luckily, the debugging cfm executes within each application. So the session and application variable scopes are available inside it.

The server debug template can alternate between the default debugging dump and ColdFire formatted output by checking for the existence of a session variable. By default, the server will append the default debug information. But each developer can set a session variable inside an application event or on individual templates to fire the ColdFire formatted output.

This is what your debug template looks like:

<cfif IsDefined("SESSION")
   AND IsStruct(SESSION)
   AND StructCount(SESSION) GT 0
   AND IsDefined("SESSION.UseColdFireDebugging")
   AND SESSION.UseColdFireDebugging EQ true>

   <!— Place the contents of ColdFire.cfm here —>

<cfelse>

   <!— Place the contents of your classic.cfm or custom debug template here —>

</cfif>

Comments (5)

cf.Objective() Day 2

Day two of cf.Objective and my brain is approaching maximum capacity. But, there’s only one more day of sessions to go.
Read the rest of this entry »

Comments

cf.Objective() Day 0

Not much to report yet. I flew into Minneapolis this afternoon, shuttled to hotel and checked in.

The welcome reception was very friendly, a good chance to mingle and put some faces to the names in the ColdFusion community. I also got to meet a few new faces — I’m always happy to dish about CF.

After a few drinks, I fear I may have disparaged Asp.NET a bit too much. I’ll try to keep it positive the rest of the conference :)

Comments

Setting Active Directory account expiration date

I needed to set the expiration date for Active Directory accounts in a VB.net web service today. Sounds simple, but it’s actually a bit tricky.

Turns out there’s a way to get around using the nonsensical large integer that AD uses to store the accountExpires field:

Dim NewADObject As DirectoryEntry
Dim ADContainer As DirectoryEntry

ADContainer = New DirectoryEntry(adPath,user,pass,authtype)
NewADObject = ADContainer.Children.Add(cn,objectClass)

NewADObject.Properties("SAMAccountName") = "newusername"

... yadda yadda yadda ...

'Set expiration date for account
Dim expireDate As DateTime = DomainAccountExpDate
NewADObject.NativeObject.AccountExpirationDate = expireDate

NewADObject.CommitChanges()

The bold bit is the pertinent section. NativeObject allows direct access to the properties of the underlying DirectoryEntry COM component. AccountExpirationDate can be set as a DateTime value.

Comments

ColdFusion on a Mac

I took the easy way out when I set up my MacBook and installed ColdFusion on a virtual XP machine using Parallels.

I’ve been meaning to take the time to get things running natively. And thanks to Matt Woodward’s setup guide, that will be a lot easier now.

Comments

Real-time Javascript debugging

If you’ve ever spent any time debugging Javascript code, you know what a nightmare it can be. You fill up your code with Alert(”message”) calls, run, try to pinpoint the problem, repeat.

Firebug is a new Firefox add-on that makes working with javascript and CSS much easier.

With this add-on you get all of the following, in the Firefox browser:

  • Line by line javascript debugging
  • Console output from javascript — no more ALERT(”message”) debugging needed
  • Error console for tracking down CSS problems
  • A javascript commandline
  • XMLHttpRequest traffic viewer
  • HTML source/DOM explorer

I have already used Firebug to track through a page with three pretty complex javascript include files, seeing real-time variable info. This tool rocks.

If this post is just a little bit too geeky for you, try subscribing to the non-tech LLW feed.

Comments