Lists are Overused

I think I can really make this really general statement: Lists are overused. We’re using lists all the time. But a list implies an order, and often that order doesn’t matter. What we want many times are sets.

Today I tracked down a bug that had… bugged me for a while, but not seriously enough to warrant a thorough investigation: When I’m instrumenting a file A, I create a file A\_i, and then I want to rename the file A to A~ and A\_i to A. For some files, this was failing.

Today I realized that it was failing because a file A~ was already there. At first I had no idea why, but pretty soon I realized that it was there because I had listed file A twice. I shouldn’t have been using a list of files to instrument, I should have used a set.

I’ve made this observation several times, and have several times already substituted sets for lists. Today I made another effort in this direction.

Share

About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in Concurrent Unit Testing, Ramblings. Bookmark the permalink.

Leave a Reply