Jay McGavren's Journal

2008-06-04

__pre_to_s, __post_to_s...

The design by contract bits in the Ruby Cookbook are interesting if only for the fact that they got me thinking about all the options for wrapping a method. By including a module in your class, you can set up code to run before or after a method call, for a specific method or all methods. That means you can check arguments, check output, or maybe even alter the input or output.

When flipping through the Module documentation this time, my only thought was, “Oh, neat, they have #included, #extended, and #method_added callbacks. Those might be useful someday.” Well, only now am I starting to see concrete uses, and they’re potentially so powerful it blows my mind.

My main remaining gripe is how sloppy aliasing methods is. I’d rather not have a bunch of __pre_x(), __post_x(), __original_x() methods lurking under the hood of my classes. But at least it’s becoming clear that I can hide this ugliness from myself.

Read more...
2008-06-04

Have you noticed what a central notion powerup management is to many games? D and I were playing Gauntlet last night, and we knew we’d barely squeak by the level we were on. So every hunk of cheese that dropped was carefully rationed to ensure it wasn’t wasted on a mostly-full health bar. This happened on the fly, but required a bit of hasty debate.

I don’t think this is even an intentional gameplay mechanic for most games that have it, but maximum HP definitely increases the need for teamwork. I wonder if the model can even be improved upon…

Read more...
2008-06-03

Oh. My. God.

Just spent half the afternoon trying to update a field via this legacy app I maintain, only to find that it reads the value from an update file and then silently discards it. (And that’s what it’s “supposed” to do.)

And then while trying to explain my own dumbassery, my co-worker realizes that the field she told me needed fixing wasn’t even the right one. Arrrggghh!

Read more...
2008-06-03

I’ve heard from a couple places now that smaller doses of caffeine throughout the day are better than a single jolt in the morning. So I’m trying to switch to green tea, which is supposed to have less…

But it seems like four times the kick, and not in a good way. I feel like my heart is going to pump its way right out of my ribcage. And it’s definitely due to the tea - this is the second occasion it’s happened.

Diana had similar effects several years ago. What the heck is in this stuff?

Read more...
2008-06-02

Looks like my company has purchased a license for a commercial wiki to use internally. Finally, a means of documenting database tables and applications that isn’t too painful to actually use… I’d been generating HTML from POD, and that was my unique solution - everyone else had their own.

Read more...