Showing posts with label programming theory. Show all posts
Showing posts with label programming theory. Show all posts

Thursday, August 8, 2013

Writing Small Methods... No, I Mean Really Small Methods

Mouse and Elephant

Like many programmers, I've typically aimed to keep my methods small. On average, my methods have been probably around 8-12 lines long. But lately, I've had a blast

Wednesday, June 26, 2013

Unit Testing: What's a Unit?

We all know that we should be writing unit tests, but have you ever thought about what a unit is, exactly? Most definitions out there, including the one on Wikipedia, describe it as the smallest piece of code that can be tested.

But what does that mean? The answer to that question will

Tuesday, May 21, 2013

3½ Ways to Reuse Code in ColdFusion Components

Programming languages give us a variety of options for sharing code among multiple classes. In this article, let's look at the 3½ ways that ColdFusion allows us to get code reuse in our components.

Let's start with a problem – we've got two

Monday, January 28, 2013

What vs. How

Have you ever had this happen to you? -- You're wading through code, analyzing one expression after another. After getting forty lines into the method, you pause and ask yourself, "Wait, what is this method supposed to do again?" It's easy to miss the forest for the trees.

This happens a lot when the code is

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

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,

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.

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.

Profile Picture
Dave Leeds
My Hobbies:
  • Programming
  • Cartooning
  • Music Writing
Full Profile