Archive for the ‘Programming’

How was this working?

July 29, 2010 By: Erik R. Category: Geeky, Programming, Weird

Friendly Bug!An oversimplified description of my job as a computer programmer goes something like this.

  1. I get some requirements for a program from my boss or a client.
  2. I write the program as perfectly as I can.
  3. I test the program with all the cases that I think it will need to handle.
  4. The program is done and people start using it.
  5. For whatever reason the requirements change (or a bug is found), and I have to go back and modify the code. Inevitably less testing is done on these changes than the original writing.
  6. Go to #4.

It’s pretty rare for the original writing of a program to have a significant bug in it after testing, although I’m not perfect. Almost all bugs are introduced in step #5. When you first write the program, the entire program and its relationship with other programs is in your mind. But when you go back to look at old code, it’s just not fresh in your memory, and it’s very easy to make a change without taking into consideration all the consequences that change will have.
(more…)

XML Renderer in Clojure

September 08, 2009 By: Erik R. Category: Geeky, Programming, Reviews

clojure logoI’ve spent the past few days playing around with Clojure. Clojure is an implementation of Lisp, the most powerful programming language, that compiles to byte code that runs on the Java Virtual Machine. I won’t go into just how awesome that is, but there are many technical reasons why this platform decision is equivalent to standing on the shoulders of giants.

Clojure comes with a built-in library for parsing XML files into Clojure data structures, but, for the life of me, I could absolutely not find any implementations that went the other way, to render XML from the Clojure structure that the default parser creates. So I wrote one…in 25 lines of code.
(more…)

Bug in java.util.EnumMap.clone()

May 08, 2009 By: Erik R. Category: Complaining, Geeky, Programming

At work today we found ourselves totally confused by the behavior of one of our EnumMap instances. No matter what we did to it (setting new values, clearing, etc.), when we iterated through the entry set, the values were the same. After investigating the source code for java.util.EnumMap, it became clear that the problem was based on the fact that the EnumMap instance we were working with had been generated by calling EnumMap.clone() rather than using the constructor. I’ve written a test program to demonstrate this bug. It should NOT behave like this!
(more…)

Lisp Enlightenment and Emacs Frustration

July 06, 2007 By: Erik R. Category: Complaining, Geeky, Programming

I have recently had my interest piqued about Lisp. I learned a little Lisp back in college for some Artificial Intelligence classes that I took. It struck me as a rather awkward language.
(more…)

Javascript Gunner

May 21, 2007 By: Erik R. Category: Geeky, Programming

Welcome to the Javascript Gunner page. This little script that I wrote is an example of the kind of thing that can be done with the javascript <canvas> tag and a little imagination. Why should your drawings be confined to the <canvas> tag when the <canvas> tags themselves can be moved around the page?
(more…)

The Shadower – Realistic Drop Shadows in Javascript

December 04, 2006 By: Erik R. Category: Geeky, Programming, Wordpress

This has been done before, but not in such a simple and elegant way, in my opinion. This implementation has four important features that separate it from the rest: no images, no messy nested divs in your html code, no CSS, and realistic fading shadows!
(more…)

Multiple Inheritance in Java

October 23, 2006 By: Erik R. Category: Geeky, Musings, Programming

I have come up with a way to accomplish multiple inheritance1 in Java using interfaces with static inner classes, which I will now present to you.
(more…)