Archive for October, 2006

“It’s everywhere…”

Saturday, October 21st, 2006

Some context: yesterday was my last day of work at my former employer. My new job starts Monday.

I’m sitting in what seem to be endless meetings at my former employer’s corporate headquarters (which is not here in Austin). An old co-worker, who resigned some time ago, is also present in these meetings. I wildly interject a couple of times and say inappropriate things, offending some of the old guard present at the meetings. By the time the next meeting is being organized, I decide to walk out and not tell anybody.

Walking out of the office puts my in downtown Austin. I wander up and down Congress a bit, poking into some weird old shops… I look in a costume shop and purloin an office chair; I literally wheel it out of the shop and get halfway across the street when the proprietor stops me. She scolds me, I make some lame excuse (returning the chair in the process), and then she begins to lament about how someone returned the hooker costume in the night (it’s early morning) and the morning dew might have damaged it. The costume isn’t anything sexy or revealing; it looks like mummy wrappings, off-white gauze, with what look like tapioca-yellow salad forks for claws? Hands? I’m not sure.

I begin to move toward the capitol that has a south mall that looks a lot like UT’s south mall. A grand wedding is taking place so I try, as much as possible, to make my way through the proceedings (Is it the ceremony? Or the reception?), trying not to get in the way of people in formal wear taking pictures, staying away from the wedding party… I find myself in some temporary reception hall, some large tent. There are tables and chairs everywhere, and some unidentifiable stage equipment set up near the entrance I just walked in.

As I make my way towards the opposite entrance to get away from the wedding, I skirt a girl who is playing a small, Casio keyboard on a keyboard stand near all the equipment. The keyboard is the type that has only about sixteen or eighteen keys and has loads of silly sounds that are more annoying than fun, no matter what their marketing department thinks. She’s plunking out some aimless melody. As I pass her, though, she plays the theme of a song I wrote when I was sixteen, my “show-off” song, my friends’ favorite. How could she know this song? I turn around and march back up to her.

“Where did you hear that?” I ask her.
“That song? Oh, it’s everywhere,” she replies airily.
“I wrote it.”
“No way! Prove it!”

So I attempt to play different parts of the song on that tiny, sad keyboard… it turns out that there are three bands of color on each key and only the lowest band sounds like a piano note; the other bands are all strange whistles and sighs, the weird Casio sound effects I never like. After some messing around, I play various bits of the song back to the girl and she’s so surprised that she’s found me.

Cat Wheel

Thursday, October 5th, 2006

PTB, please don’t take down YouTube. I love them too much.

Most Freaky Avatar

Thursday, October 5th, 2006

So I’m lurking around digg (like ya do) and I came across the Most Flirtatious Avatar? story.

So I slouched on over to see this flirtatious avatar:




This fascinates me (it helps that she’s pretty). WTF? I love innovative advertising and I love spotting viral corporate advertising (herding cats anyone?) but this is something else… is this exploitive? Was this on purpose? Did she have a director telling her to mouth words, smile, shift, lean forward, all that? To what purpose?

Am I blowing this out of proportion?

Robert Anton Wilson needs our help

Tuesday, October 3rd, 2006

RAW needs our help!

This guy’s writing changed my life. The Illuminatus! Trilogy should be required reading for weirdos. To quote the original article…

Any donations can be made to Bob directly to the Paypal account olgaceline@gmail.com.
You can also send a check payable to Robert Anton Wilson to
Dennis Berry c/o Futique Trust
P.O. Box 3561
Santa Cruz, CA 95063.

From the story at BoingBoing, RAW needs our help

Question on Generics

Tuesday, October 3rd, 2006

Suppose I have an event reactor pattern set up like this:


public interface IEventDispatcher
{
void Subscribe(IEvent newEvent, EventDispatcherHandler handler);
void FireEvent(IEvent newEvent);
}

public delegate void EventDispatcherHandler(IEvent newEvent);

public interface IEvent
{
// ... meaningful eventing stuff goes here ...
}

 

This is all well and good as it decouples senders and receivers, blah blah blah… And in the real code these are all in separate files and all that jazz.

Anyway, something I’ve noticed many times in doing event dispatcher patterns is a tendency for these “events” to become “commands” as well… so you might have the “SaveThing” class… but then you’ll add the “ThingSavingEvent” class (which is cancellable) and the “ThingSavedEvent” class. For every “command event” you’ll have the pre- and post-events as well.

And what do they teach us about code duplication? ( =

So here’s what I wanted to do:


public interface ICommand
{
// ... do command stuff here ...
}

public interface ICommandExecuter<t> where T : class, ICommand
{
void DoCommand(T command);
void UndoCommand(T command);
}

public class CommandRegistry
{
private IEventDispatcher dispatcher;

void RegisterExecuter</t><t>(ICommandExecuter</t><t> executer) where T : class, ICommand
{
 // register executer here
}

void Execute(ICommand command)
{
 // fire precommandevent for this command
 // iterate over each command executer instance for that command
 // fire postcommandevent for this command
}

}

// here's the part I'm pretty sure won't work...
public class PreCommandEvent</t><t> : IEvent where T : class, ICommand
{
}

public class PostCommandEvent</t><t> : IEvent where T : class, ICommand
{
}
</t>
 

Here’s how it works: the CommandRegistry gets a bunch of ICommandExecuter<> instances for different commands… the SaveCommand, the ExitCommand, and so on (eventually I want to put something in the CommandRegistry to maintain order, to make the command executers transactional… but I digress). Before the CommandRegistry iterates through the executers it constructs and fires a PreCommandEvent<> of the appropriate type. Here’s a concrete example.

1. Program needs to throw the SaveCommand which implements ICommand.
2. Program calls registry.Execute(new SaveCommand());
3. Registry constructs an instance of the type PreCommandEvent and fires it
4. Registry finds list of ICommandExecuter
and calls DoCommand() on each one
5. Registry constructs an instance of the type PostCommandEvent
and fires it

Steps 3 – 5 are the problem here. The language does not support doing things like this:


IEvent ev = new PostCommandEvent(typeof(command));

 

That just doesn’t make sense. Passing a Type object in isn’t syntactically correct there… the type name is what’s expected. And not a string, either.

So, yes, I know I can do some reflection to generate the an instance of the appropriate type… and it’s not that I think reflection is hard, or anything like that… but a lot of the reflection examples depend on the run-time type of an instance of a generic type looking like this: PostCommandEvent`1[[SaveCommand, ]] Isn’t that implementation specific? Wouldn’t that code have to create the type in a different way on Mono (assuming that the Mono programmers track closed generic types differently)?