I just wrote the following line of code as part of an implementation of a bucket sort.
bucket[(array[j]/static_cast<int>(pow(10.0,y)))%BUCKETS].Enqueue(array[j]);
Somehow I feel wrong inside about it. Look at it, it’s fairly complicated. In the context of the program you could work out what it was doing, but the effort would be made easier if it was rewritten as this.
int temp = ( array[j] / static_cast<int>( pow(10.0, y) ) ) % BUCKETS; bucket[temp].Enqueue(array[j]);
Just splitting up that nasty math part from the method call clear up a bit of the ambiguity of what the line is doing, and the next version is even better.
1 2 3 4 5 6 7 8 9 10 11 | // Returns a set number of digits from an // integer in the array, based on the number // of buckets and the current iteration. // For example: // array[j] = 123456; // y = 4; // BUCKETS = 100; // Then: // temp = 12; int temp = ( array[j] / static_cast<int>( pow(10.0, y) ) ) % BUCKETS; bucket[temp].Enqueue(array[j]); |
While this doesn’t really tell you whats going on, it can lead you to finding the pattern involved. That pattern is described thus:
For an integer N, the digit X positions to the left of the least significant digit is: (N/10^X)%(10^Y) Where Y is a “look-ahead” to retrieve the next-Y digits as well.
Thats my informal definition mix for base 10 numbers, derived from a few dozen minutes of fighting with bc. I could put this information into the program, and then deciphering it’s workings would be a snap. But why? I mean, I’m never going to use this again, and if I need to, I worked it out the first time, the second shouldn’t be any harder. How much documentation is too much? How much is too little?
I hate bloated files, sources that are so filled with comments you never see any code. I think (like many before me) that code should be self-documenting as much as possible. I don’t belive in using in-line comments. They get in the way and don’t often help. But I’ve also always thought you shouldn’t break out the comment blocks for anything that wasn’t “serious”, so do I lower the definition of a “serious” comment, or do I throw away my would-be in-liners?
I suppose this is one of those things that comes with time, but I’ve tried to maintain old code before, that someone else wrote with zero comments, and it’s impossible. I think I’ll err on the side of caution, for whoever comes after me.
Posted September 19th, 2006 - PermalinkLast night I was browsing through my music looking for something to go to sleep too. Eventually I found Analog’s “The Contention”, which, in high school, was a sure-fire sleep inducing album (If you ever heard Analog back in their 402 rocking heyday you might find that surprising). Somehow this time, it didn’t work. See, I hadn’t listened to that album in a long time, as in three-plus months. All I could think about was all the memories of high-school weekends spent at the Ranch Bowl or Ryans basement or wherever.
I think that everyone has songs or albums that defined their high school years, and maybe even helped shape who they are. So I wondered what mine are, and thus here is the list of the most influential albums from my glory days.
Action
by Punchline
Action is an amazing album. I saw Punchline and Allister at the Ranch Bowl, they were amazing. Punchline was my favorite band for a good few years. Action is so poppy it’s unstoppable. I didn’t really get into their newer release, 37 Everywhere, but I saw them a few months ago and they still put on a great show. Another disc of theirs, Rewind, is really good too. This album most likely had the most play time, the only other contender is…
Take This To Your Grave
by Fall Out Boy
Now, before you get all excited (”Omigosh! FOB is the best evar!!”) or pretentious (”Ugh, FOB is soooo pedestrian.”) listen up. Adam Hike introduced me to Fall Out Boy back in ‘03, right after TTTYG came out. Back then we could go to FOB shows at the Ranch Bowl for $7 and be one of thirty people there. Also Pete Wentz didn’t wear makeup at the time. Bleah. I’m not trying to “one up” anybody, I just get mad that I can’t wear my old school FOB shirts because I’ll look like a Hot Topic loser. And yes, Mr. Spiked Black Jeans, you are a loser. Anyway, I digress.
The Contention
by Analog
One of my youth pastors took me to my first hardcore show, I think it was Paria and some other locals. This was back when I wasn’t really into music, just listened to the radio and went with the Christian music standards like Newsboys and Jars Of Clay. Needless to say, I was shocked and amazed, this stuff was [u]awesome[/u]. The best local band was Analog. They were the perfect mix, they had great music and an awesome screamer. This cd is really good, and was the gateway album to my metal/hardcore addictions.
So Long Astoria
by The Ataris
There is no better album for the ride to and from the drive-in movie on a cool summer evening in Ryan’s convertible camaro. The Ataris really hit the nail on the head with this one. “Boys Of Summer” is the best cover of all time, no joke. My personal favorite song is “All You Can Ever Learn Is What You Already Know”, powerful lyrical imagery. Second place goes to “Bonus Track One” for the lines: “The things you make me want to do. I’d rob a quickie mart for you. I’d go to the pound and let all the cats go free, as long as you’d be with me.” This is one of two CD’s that I’ve actually bought twice because I wore out the first copy.
I Don’t Know You
by Lola Ray
This is a band from New York, they were filling in some show dates for another band that couldn’t make it. I don’t remember what band or what tour, but I’m glad they did it. Crazy band to see live, the lead singer / guitarist had an interesting method of “rocking out”. He would go into spasms, it looked like he was having a seizure standing up. Crazy good band with some crazy good songs.
I told myself to make a list of the top five only, but here are the ones that fell a bit short. You could call them “Honorable Mentions”…