Tuesday, December 18, 2012

What Didn't Go Wrong?

As programmers, we love developing new features. After all, it's fun! And afterward, you can fire up the app, point to the feature, and say "See that? I made that." And if it's a helpful feature, your customers are happy, which probably means you get more sales, which increases your profits.

There's another side of development, though – one that's easier to overlook. These are projects that involve things like

Tuesday, December 11, 2012

UML Diagramming Tools

I'm a big fan of UML -- especially class diagrams. I'm also a big fan of free. So I figured I'd put those things together and give you a quick review of some of the free UML tools out there!

Wednesday, December 5, 2012

Inheritance, Interfaces, and Abstraction in Two Dimensions

Previously, we explored the benefits of using interfaces in object oriented programming, noting that the key benefit was polymorphism that's detached from inheritance trees. Today I wanted to take a quick look at the relationship of inheritance and interfaces from another angle.

Both inheritance and interfaces are ways to achieve abstraction, but they have different trade-offs, and it's good to know what they are, so that when you're designing your software, you use the right tool for the job.

The Disadvantage of Inheritance

As we saw previously, inheritance has a particularly crippling disadvantage -- once you

Wednesday, November 28, 2012

Why use Interfaces in Object-Oriented Programming (OOP)?

Previously, we looked at what interfaces are, and how some languages provide an Interface type, allowing you to formalize the exposed parts of your classes. Today we're going to consider the problems that an Interface type is designed to solve.

So, why would you want to use an Interface?

Interfaces give you polymorphism that's unshackled from any inheritance hierarchy.

Now, polymorphism is one of those

Tuesday, November 13, 2012

Leeds' Reads - Game Coding Complete

You know you wanna make a game.

Like all good kids, I loved playing video games when I was growing up. Mario, Link, and Mega Man all have a special place in my heart. But being a bit of a dreamer, simply playing video games wasn't good enough for me. I wanted to make them. And that's what got me into this whole computer programming business to begin with. I probably programmed dozens of homemade video games in GW-Basic and QuickBasic growing up, and, of course, gave up on many of them before they were done.

Although I'm not a professional game developer, I'm fascinated by the art, because it solves unique problems and pushes technological bounds as far as they can go. But most of the game programming books out there are introductory level only, and don't explain anything about the full architecture of "real" games. And that's where Game Coding Complete comes in!

Wednesday, November 7, 2012

What are Interfaces in Object-Oriented Programming (OOP)?

Interfaces in the Real World

Before we dive into OOP, let's think about interfaces in the real world.

This is an interface:

Light Switch

This is also an interface:

Manual Transmission

And, so is this:

Door Knob with Keyhole

These are all interfaces that allow me, an external consumer, to interact with the system behind it.

  • The light switch is the interface that allows me to turn a light on or off.
  • The gear shift in my car is the interface that allows me to interact with the transmission. (Yes, I’m a manual transmission guy!)
  • The keyhole is my interface to the locking system of my door. It's what I interact with in order to lock or unlock my door.

It's important to notice that,

Thursday, October 25, 2012

Code Review Best Practices - Live Code Reviews

Most of the time, I prefer using tools like Crucible for conducting code reviews because they allow you to think through the code on your own time, at your own desk. You can read a chunk of code, think about it, scroll around the file, and if you're so inclined, comment on it. And the next person can do the same.

But there are times when a code review needs to be done in person. Maybe you don't have code review software, or maybe the code change is urgent. For those cases,

Wednesday, October 17, 2012

Is ColdFusion an Object-Oriented Language?

ColdFusion's been around for a long time now. Having over a dozen years of CF development under my belt, I suppose I'm a bit of a veteran, and I've seen it through a number of significant milestones. One question that I hear from time to time is this: "Is ColdFusion an Object-Oriented Language?"

Wednesday, October 10, 2012

When work follows you on vacation

So, last week my wife and I went to the beach for a week of vacation and fun in the sun. Hundreds of miles away, after half an hour of a bike ride, and at the very end of a half-mile long pier, I saw the "CF+JS" etched into the wood railing.

ColdFusion and JavaScript apparently follow me everywhere!

(But seriously, I actually did some hobby coding while I was on vacation. After all, it wouldn't be much of a vacation if I didn't get to relax and write some code...)

Thursday, September 27, 2012

You Should Care

On development teams, and pretty much all teams, it's not unusual to hear the phrase "I don't care" thrown around. Here are a few examples:

  • "I don't care which solution you go with."
  • "I don't care if you have to take shortcuts, just get it done."
  • "When dealing with abstractions, I don't care about implementation, I just call a method."
  • "I don't care how much load you throw at it, this new caching solution can handle it!"

What do we actually communicate when we say this phrase? It's become so casual and colloquial that most people don't mean anything severe when they say it. But underneath the phrase are connotations of superiority and aloofness that aren't usually intended but often received by the listener.

I decided years ago to drop the phrase from my vocabulary, and replace it with more supportive and descriptive options, such as:

  • "I'm fine with either approach."
  • "At this point, I'm much more concerned about getting this out on time than I am with factoring the code properly."
  • "When dealing with abstractions, I call the same method regardless of the implementation."
  • "With the caching solution in place, we can handle thousands of requests each second."

It's our responsibility to care about things like users, teammates, code, performance, and time to market. I dare you to try replacing this phrase for one week, and see what a difference it makes, both in your attitude and your coworkers' attitudes!

Monday, September 17, 2012

Sublime Text 2 Snippets

So at work recently, I began using Sublime Text 2 for my ColdFusion and JavaScript programming. So far, I really dig the way it's both developer-focused and simple. For example, to edit your preferences, you modify a JSON file. See what I mean? None of those crazy properties pages. Just simple. If you're a developer.

Anyway, one thing I missed quickly from ColdFusion Builder / Eclipse was all my handy dandy snippets. You know, type a character or two, hit Ctrl+J and BAM! you've got the outline for a class or function. Or whatever you want, really.

Well, when I tried adding my snippets to Sublime, I had a little trouble getting them up and running. So here's how you do it!

Wednesday, August 22, 2012

Code Review Best Practices - Formatting Standards

Many development teams spend an inordinate amount of time arguing over styling and formatting preferences, such as:

  • Whether to use single quotes or double quotes
  • Whether curly braces go on the same line or the next line
  • How to wrap long lines of code

Although these preferences are somewhat subjective, there's something to be said for consistency. Imagine you're reading a book where one page is double spaced and the next is single spaced. On one page, important terms are bolded, and on another page, important terms are underlined. As a reader, those types of inconsistencies can get between you and the content of the book. Likewise, in code, these types of styling and formatting preferences do make a difference.

Since styling comes up frequently during code reviews, it's a good idea to have a strategy in place for dealing with it. Here are three levels of maturity for dealing with code formatting on a development team.

Wednesday, August 1, 2012

Code Review Best Practices - Review Everything

Welcome to the second part in a series on best practices for code reviews. Last time, I explained why I believe it's important for everyone on the team to chime in on code reviews -- rather than having a single gatekeeper, it's important for everyone to share that responsibility.

Today I'm discussing the flip side of the coin -- everyone's code should be subject to review. I believe even the technical leads should submit their code for review. Of course, it's tempting to let their code slip by because, hey, if they don't write code that passes the team's standards, then who the heck does?!

But there are actually very good reasons to subject even the technical lead's code to review. Here are three of them:

Wednesday, July 11, 2012

Code Review Best Practices - Everyone Participates

Most programmers agree that it's easier to prevent technical debt than it is to pay it off. And one of the best ways to prevent sub-par code from ever seeing the light of day on a production box is to have a solid code review system in place. Over the years, I've discovered some practices that have really made a difference for me. Here's the first in a series.

Although it's traditional to have the technical lead be the "gatekeeper of the code", I believe everyone on the team should participate by reviewing the code. Here's why:

Thursday, June 21, 2012

CSS3 3D Transform Playground

In previous posts I reviewed the different types of CSS3 3D transform functions and the significance of the order in which they're applied.

For your entertainment, I've whipped together a playground where you can apply different values to an image, to see how it affects things. Use the sliders to increase or decrease the values. The resulting transform value is shown below, in both expanded and matrix3d varieties. Presently works with Webkit and Firefox. Enjoy!

Thursday, June 14, 2012

CSS3 3D Transforms - Function Order Matters!

Previously, we explored the basics of CSS3 3D Transforms. A transform is generated by using one or more of the 3D transform functions, like so: If you're not careful, you'll find that the elements you're trying to manipulate in 3D space don't look like you'd expect. This can happen when

Wednesday, June 6, 2012

How Model-View-Controller (MVC) Relates to Application Architecture

Ben Nadel's recent post on MVC and Application Architecture stirred up quite a few comments! It also sparked tons of thoughts for me about my own journey with application architecture.

Years ago, when someone asked me to describe the architecture of a particular application, I remember saying in a chipper tone, "Why, it's using MVC!" But I've learned a lot since then, and I want to share some of my thoughts on how MVC fits into the greater picture of Application Architecture.

Tuesday, June 5, 2012

CSS3 3D Transform Basics

3D transforms in CSS3 are just plain fun and easy. A transform represents a series of functions that you can apply to manipulate an HTML element in 3D space, and they include the following:

  • Translation
  • Scaling
  • Rotation

Let's take a look at each one!

Thursday, May 31, 2012

Animating a List with CSS3 Transitions

As I've been exploring all the cool features of CSS3, I've been trying to keep in mind cool ways to put them to use. CSS3 Transitions are so sweet and so easy that they can really make for much richer and interactive web sites with hardly any effort. And when a browser doesn't support it, it's not that big of a deal -- the elements still end up getting the correct properties... the user just doesn't see the animation.

I wanted to see how CSS3 transitions could be used for animating a sortable list. In this case, I've got a leaderboard for a video game competition. Let's see who's winning at the moment...

Wednesday, May 30, 2012

ColdSpring - Including External Files

ColdSpring is basically the boss of Dependency Injection in the ColdFusion world. As faithful Divide & Conquer programmers, it's not unusual to want to split up our monolithic ColdSpring XML file into smaller files.

I, for one, can never seem to remember how to include those smaller files. That's because in the ColdSpring world, it's not called including – it's called importing. And here's how it's done:

And now that I've written a blog post about it, maybe I'll actually remember it – without having to look it up!

Thursday, May 17, 2012

CSS3 Demo - 3D Transforms

CSS3 introduces some awesome 3D transforms that let you position, rotate, and scale your elements in 3D space. It's still in working draft status, and today it's only supported in Firefox and WebKit. IE has plans to support it in version 10.

Now, I'm a bit of a hobbyist when it comes to Flash and After Effects, and I've prototyped a few incomplete 3D games using DirectX. So I felt right at home with the CSS3 transform property. If you haven't worked with 3D transforms before, don't worry. I'll cover the details of it in a later post. For now, check out the demo.

Monday, May 14, 2012

Dead Drop Variables

I've always found the world of espionage intriguing. I'd never actually want to be a spy, mind you. In fact, I'm really bad at lying, and I can't keep a secret. And I'm pretty sure those are prerequisites to get into spy school.

One of the simplest techniques that spies use to communicate intelligence is called a dead drop. In a dead drop, one spy leaves some item in an agreed-upon location, generally somewhere out in public where anyone could find it, but nobody would likely notice it.

Back to the Programming World

In dynamic languages with a global scope, such as JavaScript and ColdFusion, I've noticed a pattern that looks just like those old spy dead drops.

Monday, May 7, 2012

Essential Guide to an Awesome 90's Website!

10. Warn your visitors about the best resolution

Before your visitors enter your cool new website, you'd better be sure they know what resolution works best for your web pages!  Most of them will gladly right-click on their desktop, go to properties, change the resolution, hit OK, close the properties dialog, and switch back to the web browser in order to get the best viewing experience.  After all, it's not very likely that they'd already have their display settings configured to the optimal resolution.

9. Use nothing but Times New Roman font

When visitors come to your website, they want originality. Since there aren't many sites out there using Times New Roman font, you should use that. They'll think, "wow, that's a cool site with a hip font."

8. Use HTML tables

If you have stuff that you can't align any other way, the HTML tables feature is just what you need! Don't change any of the cellspacing or cellpadding values... they're perfect just as they are!

7. Use animated gifs

The way to really one-up printed media is to create what we call "animated gifs".  These are images that actually animate before your very eyes!  Visitors will be so mesmerized by them that they'll surely pay more attention to the content of your cool web page!

6. Use horizontal rule tags everywhere

The visitors of your website have to know when one section of content is different from another section, or they might get confused.  Sometimes paragraph breaks (preferably done using two <br> tags) aren't enough.  Horizontal rules to the rescue!

5. Use the marquee tag

Sometimes the best way to communicate a message is to have it on the screen only part of the time.  For this you should use the marquee tag, which moves the text across the screen horizontally.  It takes longer for your visitors to read the message when it's scrolling, and that means they'll be on your website longer!

4. Limit your fonts to 16 colors

People like to see colors, but their graphics card might only be able to handle the basic 16 EGA colors.  Use the font tag's color attribute to set the color.

And for the images on your site, you can achieve high image quality by ensuring that your images are only 16 colors but use dithering. People will be very impressed, and might even think there are actually more than 16 colors in the image!

3. Use a page hit counter

Put a counter on your page so that people can see how popular your web page is! Try to find one that looks like an odometer, and people will think, "wow, that's clever!" If your web page isn't actually that popular, open it up in a browser and hit F5 until the counter shows a high enough number.

2. Use an "Under Construction" image

You want your visitors coming back frequently, and the best way to get them to do that is by placing a cute image of a construction zone somewhere in your web page.  It can have orange cones, hazard tape, or a stick figure with a hard hat.  You get bonus points if it's an animated gif with dithering!

1. Take credit - be a Webmaster!

After all of your hard work making the perfect web page, you should take credit for your hard work by putting your name on it, and calling yourself a Webmaster!  After all, you are master of the web!

Wednesday, May 2, 2012

Slim Up Your JavaScript with CSS3 - Animation

When I was a kid, every Saturday I'd get my bowl of sweet cereal and plop down in front of the TV, ready for an action packed morning of cartoons! While I won't be using CSS to animate any Saturday morning entertainment, I was delighted to discover some sweetness built into the CSS3 working draft that'll bring those static elements to life!

Last time, I explored some basic animations called Transitions, which we used to get a button to slowly glow. But this time, I'm looking into the more advanced animation capabilities of CSS3, which gives a lot more control!

Thursday, April 26, 2012

Why every programmer should have a blog

Picture this -- It's Thursday night. You're hacking away at the keyboard, slingin' some code for a project that's due by the end of the week. Your scribbled UML diagrams on the legal pad under the desk lamp are hardly visible beneath the rings of coffee stains from all the cups you've been drinking over the past four days. You hit F5 to double check your code changes, when suddenly

Wednesday, April 11, 2012

Slim Up Your JavaScript with CSS3 - Transitions

As I've been learning about CSS3, I've been particularly interested in the ways that it can help keep my HTML lean and clean. But I was surprised to learn that CSS3 doesn't only tidy up your markup -- it can also eliminate the need for presentation-related JavaScript code! Let's take a look...

Wednesday, March 14, 2012

Slim Up Your HTML with CSS3 - Sliding Doors

The sliding doors technique, as made famous by an old AListApart.com article, has been an incredibly handy way to make buttons and tabs that can stretch dynamically based on the text. So as I've been studying CSS3, I've wondered what new features would allow us to slim up the markup. Let's take a look!

Thursday, February 23, 2012

Slim Up Your HTML with CSS3 - Zebras

Last time, I explored one way that new CSS3 properties slim up our markup by eliminating wrapping elements. But those wrapping elements aren't the only things clouding up our HTML! Another common way that it gets cluttered is with extra class names. And today, I'm exploring a way that CSS3 helps us eliminate those, too!

Wednesday, February 1, 2012

Slim Up Your HTML with CSS3 - Borders

I gotta admit, I haven't quite gotten into those skinny jeans that seem to be so popular these days. But when it comes to my HTML, I want it to be super lean! In this series, my adventures take me into the world of CSS3, where I'll discover new tricks to keeping that markup as light as possible.

Tuesday, January 24, 2012

The Trailing Comma Bomb

Well, they got me again.  Those pesky trailing commas in JSON objects. If you don't know what I'm talking about, then you probably haven't been doing JavaScript in IE7, because Firefox, Chrome, and IE8 and up all ignore them.

Monday, January 16, 2012

jQuery's .html() method, and the Undocumented Argument Type

By Dave Leeds

So the other day I was sending a JavaScript string into jQuery's .html() method, and I got this funky, funky little exception in Firefox:

Error: uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOMDocumentFragment.appendChild]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"
And in Internet Explorer, the message was this:

Thursday, January 12, 2012

Nested Statements in jQuery

As we all know, jQuery's powerful selectors allow you to quickly create an object that contains multiple elements from the DOM, and manipulate all of them in a single line. (Noob stuff, I know, but hang with me, here...) For example:


We're saying, "Find all the divs, and generate something random to go inside them." Obviously, the content will only get inserted if one or more divs are on the page.

If you were to write that instruction without jQuery, you'd probably write it a little something like this:

// Translation of $("div").html(generateSomethingRandom());
var divs = findDivs(); // a fictitious method
for(var i = 0; i < divs.length; i++) {
 div.innerHTML = generateSomethingRandom();
But, in fact, that would be incorrect!
Profile Picture
Dave Leeds
My Hobbies:
  • Programming
  • Cartooning
  • Music Writing
Full Profile