Oh, I got hot sause all over my bazito!

You know what this is? It's a brain sucker. You know what it's doing? Filing its tax return

If you wish to make an apple pie from scratch, you must first invent apple pie

The Adventures of Little Ed Brave

Tell airport security your name is McCannister because you can hide anything in a cannister.

You know what? Nobody notices when this changes anyway.

There are 10 types of people in the world: Those who understand binary, and STFU

What happens in a black hole stays in a black hole

The black hole draws you inexorably inward. Time slows. You are likely to be eaten by a grue.

I'd diddle little umdidlie... if she weren't my half-sister.

Abortion prevents pedophilia. In more ways than one!
Get Firefox!
I wrote a haiku

which I was about to share,

but then I thought, "screw it."
Level 1

Notice to all users of the Holodeck:

There are safety protocols in place that cannot be deactivated without the approval of two commanding officers or the captain to protect users of the Holodeck from potential harm. However, every time the Holodeck is ever used in a nontrivial manner, no matter what the safety protocols say, the Holodeck turns into a deathtrap.

Unless you believe yourself to be adept at constructing a forcefield from your communicator and 19th century Earth tools, or you're at the very least not wearing a red shirt, you are strongly advised not to attempt to use the Holodeck until a designer comes up with a safety protocol that doesn't kill you whenever somebody looks at it funny. Even when you're not on the holodeck. Or in the same quadrant. Or time period.

In fact, if you are wearing a red shirt, Starfleet may not be the job for you

« Got that monkeyAliens invade Earth... for real this time! »

When all you have is a nail...

Permalink 05/06/08 at 07:21:34 am, by Ed, 532 words   English (US)
Categories: School, Programming

You know the old adage "When all you have is a hammer, every problem looks like a nail". Well, I'm in my stagecraft class, and we regularly have to reverse that. That is, "When all you have is a nail, every tool looks like a hammer." Which I'm sure many of us have experienced in the past, driving in a nail with the but of a screwdriver, the battery of a cordless drill, a caster, a different piece of wood, a belt sander, a router, the butt of your hand, a jigsaw, or in the rare cases when you're feeling industrious, a hammer.

Honestly, the hammer is just about the simplest tool in any shop, and we rarely use them. We just take what we have and use that instead. Why don't they just put a ball peen on every power tool they make? It'd save us the trouble of getting up and actually fetching a hammer to drive the nail in all the way so that the jigsaw doesn't jump when it hits it, or the sand belt doesn't break when it files down the nail head into nothing, or god knows what would happen when the router comes near it.

But that's not the only place I've seen it. I've seen it in programming, having been guilty of doing it myself some times as well. Most recently, for example, I have a very simple "node" object which in ones mind one already knows what it is. It's a sub-object of a parent object that needs several objects arranged in a certain way. Nodes are used everywhere in programming. In this case, in a self-balancing binary search tree I've used for a project in a class. This node has grown to contain:

  • a left and right child node (indisposable in a binary tree)
  • a parent node (also very useful)
  • a value (what's the point of having a node without data?)
  • a key (okay, self-balancing trees need something to sort by)
  • a left and right child height (I guess it's okay to cache the height so as to not recalculate it every time)
  • an article count (okay, that makes s--What!?)
  • the current article (Wait up! I'm still stuck on the last one!)
  • the IDF (Random unexplained acronyms abound!
  • and the phrase length (I give up)

It should have been so simple! It should have gone no further than the key! Maybe have a child height, but no more! Every time we needed the program to do something else with the data, I stuck it into the node as a new data value. The IDF isn't even used in the first half. In fact, it isn't even used in relation to the self balancing tree! I reuse the nodes to get away from having to create a new object to create a list of items linked by parent and child. I'm essentially using a left-right node as a left-only node and foregoing all operations supplied by the tree entirely.

Like I said, when all I have to do is sort, every tool looks like a self-balancing tree node. Yeah, that's right! I pulled it all back together! Didn't see that coming did you?

No feedback yet

Comments are closed for this post.