Wet, loud, yet way too polite

Matt, Kyle, and I having lunch together yesterday and Matt brought up the concept of Tell, Don’t Ask.  Matt was saying that you shouldn’t have to examine an object to figure out what method to run, instead give your data to that object and let it figure it out.  Later we were continuing our conversation and Blaine piped in on on the Pragmatic Programmer’s article OOP in One Sentence (PDF). I read it and I couldn’t remember ever seeing it before.

All of this bounced around in my head during the night and, on the way to work, I decided to stop being frustrated on the code I inherited and start making changes.  So that’s how I spent the better part of my day.  And I knew the code was bad, but I didn’t know how bad until I started digging through it.  And the more I dug, the worse it got.  Ugh.

The worst was the Action class that used three arrays for the same thing.  Yes, three arrays.  One held the data, the second one was a copy of the first one, and the third was a subset of the second one (i.e. also a subset of the first).  After an hour of work and panic, three Arrays became one ArrayList.  I figured it was least cleaner this way.  But wouldn’t you know – performance was noticably better.  I mean, I wasn’t copying the same Array three times anymore.  Small wonder.

Still more work to be done, but it’s a good excercise for me to familiarize myself with code.  And I can always claim the performance gain I just got.

Leave a Reply

You must be logged in to post a comment.