codethinked (kōdthĭngked) adj. To be consumed by or obsessed with code.

How The U.S. Census Can Make Your Software Better

Form

You might be thinking, what kind of silly question is that? The census is produced by the government, and everyone knows that the government can't do much of anything correct. Right? Well, today I received in the mail the same letter from the U.S. Census Bureau that people across the net have been decrying for a while now. It is a thin envelope, and inside of it is a letter letting me know that in about a week I will be receiving a census form. At first glance you might think "What a waste! They mailed you a letter to tell you that they were going to mail you something?!" In the immortal words of Tracey Morgan, "That's just crazy!" And at first, it does seem that way, but I think that the truth is a bit more involved.

Continue reading the rest of this post...

The TekPub LINQ Challenge Part 2 – Faster Algorithms

In order to challenge others to the TekPub LINQ challenge, I felt like I had to create my own solution first, before I challenged anyone else to the task. What I came up with is an algorithm that works, and is also terribly inefficient. There are a few optimizations that can be made in order to speed it up though.

My original solution looked like this:

var primes = Enumerable.Range(1, 20)
    .Where(i => i != 1 && !Enumerable.Range(2, i - 2).Any(j => i % j == 0));

Here you can see that we take our range, check to make sure that 1 is not involved (since 1 is not prime!) and then take the range from 2 to one less than the number and then use “Any” LINQ extension method to check to see if any of the numbers in between divide evenly into it. A brute force approach, which works, but it is not super efficient.

Continue reading the rest of this post...

The Static Spider Web Pattern

SpiderWebSmall

"I'm picking up your sarcasm." "Well, I should hope so, because I’m laying it on pretty thick."

–Tommy Boy

While the developer lexicon is loaded up with more patterns than we can possibly ever learn, I just wanted to introduce one of the more important patterns that I think exists out there in software development. I call it the “Static Spider Web” pattern. The main driver behind this pattern is that object instantiation, allocation, and deallocation impose far too much overhead in modern programming language runtimes. Since we aren't in direct control of memory management, and since garbage collectors on systems with large amounts of memory can cause huge latency overheads, we need to find some way to minimize, at all costs, the number of objects that we allocate.

First, we are going to have to just accept the fact that we will have to create a few objects. I mean, our application data needs to go somewhere, right? I'd advocate for passing the data around as parameters, but that would get old pretty quick with all of that typing. Besides, that is what objects were invented for, to be stateless data containers.

Continue reading the rest of this post...

The Law of Unintended Consequences

SnowBlowerSmall

Bet you never thought about it, but Energy-efficient traffic lights can't melt snow. Talk about the Law of Unintended Consequences. You want to save money by buying more energy-efficient traffic lights, but then you end up spending an untold amount of money on traffic light cleaners, or potentially, the EMS/Police who have to deal with the aftermath of stop lights not working after heavy snows. Then there are the health insurance costs, department of transportation costs to fix the barriers that might get damaged, car insurance costs, etc... The consequences are complex and far reaching. But once you see it, it just seems so obvious! Of course LEDs aren't going to melt snow, they don't produce very much heat at all!

Unfortunately, while using incandescent bulbs, this wasn't a problem. So it wasn't a problem that they knew needed to be addressed. Trust me, if incandescent bulbs didn't melt the snow previously, then you can be guaranteed it would have been at the top of their list to find a solution to this problem. But they picked a solution based on one factor that brought some other problems along with it.

Does this sound familiar? If you are a software developer, it should. You probably have to deal with some of the most complex systems that have ever been devised by humans. Thousands of inputs, outputs, moving parts, pieces of business logic, and probably a team of about 5 people to do it all! Right? Of course, companies often don't have the resources to bring in dozens of developers to write a really great system, they just need a "good enough" system to allow them to function.

Continue reading the rest of this post...

It’s Okay To Write Unit Tests

I hate these posts. I hate them because I feel like I am drawing attention to another post which made me cringe a little bit. But I think that reacting to these posts is good, because having a healthy debate about topics is good, especially if you can keep from devolving into mud slinging and attacks. The post I am talking about is this one, which is titled “It’s OK Not to Write Unit Tests”. I was surprised to see that it is actually from March of this year, and maybe I have seen it before, maybe not, but this time I felt the need to respond to it.

One thing that I want to say first is that I want to keep this calm and mellow. I used to react very calmly in retort to this kind of post, but over time as I wrote more and more on my blog, I found myself starting to become the “everything is black and white and I’m going to tell you that you’re wrong with my blaring megaphone” kind of writer that I often loathe when I read. Sure, it might not make the best link-bait in the world, but maybe I’ll feel a bit better after I write it. Oh, and the blood pressure might stay down a little bit. Having said all that, here we go…

Continue reading the rest of this post...