## Counterexamples and Proofs

August 11th, 2012

Memo to self: when attempting to prove a theorem, and it just doesn’t seem to be working; don’t forget to search for counterexamples. The theorem may not actually be true.
Read the rest of this entry »

## 1% Problems

July 22nd, 2012

I hate 1% problems. No this isn’t an OWS slogan. I’m thinking of those code issues that really aren’t a problem 99% of the time, but when they bite, they’re really hard to debug and they cause real pain. Several common cases in Java:

1. Using java.util.Date or java.util.Calendar instead of JodaTime.
2. Not specifying a Locale when doing language sensitive operations such as toLowerCase() and toUpperCase().
3. Not escaping strings passed to SQL, XML, HTML or other external formats.

What I hate most is that it’s really, really hard to convince other developers that these are problems they should take seriously. Read the rest of this entry »

## Don’t Design for Reuse

July 14th, 2012

Last week one of my colleagues hit me with an idea that was so obvious when he pointed it out I wondered why I hadn’t realized it before:

If you’re designing for reuse, you’re doing it wrong.

In 2012 the only code you should be writing is what’s needed for the immediate task at hand. Don’t design for reuse. Don’t consider reuse. Don’t waste one minute of your day making code reusable.
Read the rest of this entry »

## Calculating Sines without Calculus

June 3rd, 2012

One of my better math teachers in high school was John Brumfield. He taught me Algebra I and Precalculus. He was also exceptional at calculation, a skill that got him into in the artillery core in World War II, where he had to calculate gunnery firings in real time. And he had a great sense of humor. But one of the things that stands out most clearly in my memory from one of his classes is something he may have gotten wrong (perhaps deliberately). At that point in the early 1980s scientific calculators existed, but were quite expensive and not yet integrated into the high school mathematics curriculum. We were probably one of the last classes to spend significant time learning about trig tables, and how to interpolate between values. (A surprisingly useful skill, by the way, even if the reason we learned it no longer applies.) I recall that someone in the class asked him how the numbers in the tables were calculated. E.g. how did the author know that the sine of 47.1 degrees was 0.0238875315 and not 0.0238875326 or some other value? And his answer still sticks with me to this day, and I quote it word for word: “Very accurate graphs”.
Read the rest of this entry »

## Why are the Integers a Cyclic Group?

May 27th, 2012

If we follow Wikipedia in defining a cyclic group as a group in which there exists an element g in G such that G = <g> = { gn | n is an integer }, then the integers under addition are clearly a cyclic group with the generator 1. But why do we define cyclic groups that way? Or, another way of putting it, why is the definition given the name cyclic when there’s nothing cyclic about it?
Read the rest of this entry »