March 2008

Client, server, client environment, server environment…

OK, here’s part of what I’m thinking…

#Ensure server is authority on object movement by default.
def test_server_movement_authority
	@server.start
	@client.connect
	@client_environment << @object
	server_object = find_matching_object(@object, @server_environment)
	#Move client object one way, server object another.
	@object.vector.pitch = 90
	server_object.vector.pitch = 180
	#Interact.
	@server_environment.interact
	#Ensure client location/vector matches server's anyway.
	assert_equal(@object.vector, server_object.vector)
	assert_equal(@object.location, server_object.location)
end

Basically the client runs its own environment to keep things looking smooth, but when the server finally gets back in touch with it (and it could be several seconds), any location and vector the server sends gets blown away on the client. (It won’t send all of them, just those within a given update area.)

Ruby
Zyps
development

Comments (0)

Permalink

iTunes-style folder organization…

Hrmmm, not bad:

irb(main):001:0>
Utility.cache(
	'foo',
	:creator => 'Jay McGavren',
	:title => 'Cache Test',
	:sort_order => 1,
	:parent_directory => '.',
	:extension => 'txt',
	:album => 'My Album'
)
=> nil
irb(main):002:0> puts find "Jay McGavren"
Jay McGavren
Jay McGavren/My Album
Jay McGavren/My Album/01 Cache Test.txt
=> nil
irb(main):003:0> puts cat "Jay McGavren/My Album/01 Cache Test.txt"
foo

[edited for legibility]

Ruby
development

Comments (0)

Permalink

Delayed require statements…

I have a set of Ruby utility libraries in my home directory for my own use, and it’s nice not to have to care how bloated it’s getting. Except that it was taking up to 10 seconds for even basic operations.

The main problem was my strategy of “require libraries first, ask questions later” (which is the exact opposite of my strategy when I intend to distribute something). My goal was to load everything up so I didn’t have to think about which modules I needed (or type their names). But even if all I was calling was a little file slurping routine, I got date parsing and PStore and a bunch of other stuff I didn’t need.

Moving my require statements within the methods that use them alleviated things quite a bit. Ruby doesn’t care when you load your modules, so why take the hit at startup?

def Utility.clipboard
	require 'win32/clipboard'
	Win32::Clipboard.data
end

A similar strategy is working nicely with Rake. I want to offer amenities like rSpec and ruby-prof tasks, but don’t want to make them requirements. So I don’t even define the task until I load the library successfully:

begin
	require 'spec/rake/spectask'
	desc "Run user stories"
	task :stories do
		FileList["stories/*.rb"].each {|f| ruby f}
	end
rescue LoadError => exception
	warn "Could not load rSpec - it might not be installed."
end

I’ve encountered acolytes of various languages who like to declare their dependencies right at the top of a file for all to see, and that’s a good thing. But dependency declaration is starting to move into the package your source comes in (gems, POMs, etc.), so I don’t think it’s such a big deal to have it in the source any more. If anyone knows of a pitfall I’m missing, though, I’d be interested to hear about it.

Ruby
development

Comments (0)

Permalink

Why not to put abbreviations in your code:

-It hampers searches later. You might search for “database” and miss all the references to “db”.
-It thwarts anyone for whom English is not a first language. “Config” doesn’t appear in Webster’s, much less an English to Japanese dictionary.
-Even within the same routine, you lose time and concentration trying to think whether you used “char” or “chr”.

The benefits far outweigh the time cost of a few extra keystrokes. (Unless you can’t touchtype properly, in which case you should learn.)

general

Comments (0)

Permalink

I am DONE with karaoke.

I needed something to do with my commute one day, so I popped out the karaoke CD - the one with songs I knew the karaoke bar had in their catalog. I had decided last time that I simply didn’t know how to sing, so I was going to rap. I had time on my hands, so I chose something moderately challenging (and appropriate for a suburban white boy) - “Clint Eastwood” by Gorillaz. Over the next couple weeks I put literally hours into rehearsing that song, until I could do it without lyrics or even accompaniment. When my wife’s friends suggested a trip the bar, I got bemused but enthused looks when I told them my planned selection. Late last week, Diana and I practiced together so she could be my backup singer. I know she’s biased, but she said I sounded really impressive.

Moment of truth - mics are handed to me and Diana. I get up, confident that I’m going to sound really, really white, but that I’m going to give a good performance.

And Diana and I proceed to train wreck it. The background music was really, really poor, the rhythm changed up in a few places so that neither Diana nor I were in sync with it, and the displayed lyrics were, well, not in sync with anything.

I know there are quality karaoke CDs out there, but at any given bar they’re likely to be mixed in with crap like this. Trying to choose the right song is like navigating a minefield.

So I’m done. If the karaoke companies and the bars that stock their wares don’t give a damn, why should I?

general

Comments (0)

Permalink

Yes, they have headings when you sort by message size in Outlook…

Size: Large (100 - 500 KB)
Size: Very Large (500KB - 1MB)
Size: Huge (1 - 5 MB)
Size: Enormous (>5 MB)

general

Comments (0)

Permalink

Sounding boards…

This phenomenon should not be news to anybody, but it should be a consideration in the design of any system that allows collaboration, so I need to jot something about it here…

I had a one-sided IM conversation with a co-worker earlier this week - I suspected he’d stepped away from his desk, and he had, but I was queuing it up in the log for him to review when he returned. In typing out a description of the problem I was having, I mostly worked it out on my own. The resulting “conversation” was rambling, but it resulted in a solution without my co-worker lifting a finger. He later told me that he and another team member use each other as “sounding boards” all the time, working out problems simply by describing them.

And here I am, about to go converse with another person who I know has only incidental knowledge of the system I’m working on. But I’m breaking from the usual workflow, and need to ensure I won’t cause any harm. I feel like I won’t have done my due dilligence until I’ve talked it out with another person.

design
development

Comments (0)

Permalink

Enso scratchpad demo…

I’m sure you all remember my earlier rant about Enso 2.0 and the discussion with [ICR] that followed… Well, Andreas Schuderer is even more doubtful about the new design that I - so much so that he’s done a lengthy writeup on his reasoning and a usable demo with a possible fix.

I like his scratchpad a lot better than “open notepad”, that’s for sure.

By not providing (or insisting upon the use of) an editor, Enso has moved away from the noun-verb interaction that Archy encouraged. This may be a step in the right direction again.

design
development
enso

Comments (0)

Permalink

Aza, Aza, Aza…

Bloxes. A great idea that Aza Raskin should have sold to someone else to implement.

Look, I know all about distractibility, believe me. I know about having more ideas than you could ever possibly do. That’s why you need to discipline yourself and focus. Archy was a good starting place, and a good final goal. Enso was arguably a necessary detour. (But it’s not making money any more, is it?) The music search service was, well, what the hell was it? And now you’re breaking off into manufacturing?

I have the utmost respect for you and your work. But if you spread yourself too thin, each of your projects is going to disappear the moment you turn your attention away from it.

design
enso

Comments (0)

Permalink

We’re re-implementing an old 4GL app, and my co-worker made it sound like the log scraper used Deep Black Magicks, so I had him keep that part to drive my new Java, even though it was a clunky solution. Well, now that I’m delving into the 4GL, it’s really not that bad.

I’ll be stepping on my co-worker’s toes if I re-code it, but…

general

Comments (0)

Permalink