Moving Away from State: State–

In 1968, Edsger Dijkstra issued a letter entitled “Go To Statement Considered Harmful,” and the age of structured programming was born. The letter was a call to stop programmers of the time from creating ad-hoc control flow structures using goto statements and to instead use these higher level constructs for Continue reading

The Way We Write Code is Stupid: Source Code Files Considered Harmful

Order Doesn’t Matter Please pardon the loaded phrasing in the title, but that’s how the message came to me from my subconscious brain: bluntly and without ceremony. I was doing a bit of work in Apex, the object-oriented language specific to Salesforce.com, and it occurred to me that I had Continue reading

Hilarious Conditional Bloopers!

For this Friday, I thought I’d do something a little more lighthearted and, in the tradition of bad television (or Robot Chicken’s satire thereof) post some programming bloopers. These are actual things that I’ve personally seen in source code as opposed to some kind of specific sampling of CodeSOD from Continue reading

Casting is a Polymorphism Fail

Have you ever seen code that looked like the snippet here? public class Menagerie { private List<Animal> _animals = new List<Animal>(); public void AddAnimal(Animal animal) { _animals.Add(animal); } public void MakeNoise() { foreach (var animal in _animals) { if (animal is Cat) ((Cat)animal).Meow(); else if (animal is Dog) ((Dog)animal).Bark(); } Continue reading