
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
One guy's bold adventures in the world of computer programming
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
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
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
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
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.
As we saw previously, inheritance has a particularly crippling disadvantage -- once you
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.
Interfaces give you polymorphism that's unshackled from any inheritance hierarchy.
Now, polymorphism is one of those
Before we dive into OOP, let's think about interfaces in the real world.
This is an interface:
This is also an interface:
And, so is this:
These are all interfaces that allow me, an external consumer, to interact with the system behind it.
It's important to notice that,
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.
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.
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.