elfs: (Default)
[personal profile] elfs
The little things matter.

In programming, there is The Unix Way and there is The Microsoft Way. Down in the deeps of our cultural understanding of programming, there is this:

When you ask a question of a database, you're frequently expecting that the answer will be a list of things. By The Unix Way, if you ask a database for a list of things, and your query is sufficiently restrictive that nothing in the database matches, you get back an empty list. By The Microsoft Way, if your query matches nothing, the systems thrown an exception that you are expected to deal with. Dealing with an exception is onerously heavyweight compared to just asking "Is the list empty?" I've mentioned this problem before.

Unpleasantly, I discovered this problem the other day in Django's "activity stream" plug-in: if you weren't actually following anything, then there would be no activities to show you. The plug-in didn't throw an exception, but it didn't return an empty list. It returned the Python object meaning "No object." I have successfully convinced the upstream maintainer that an empty list is better, and my patch was accepted.

It seems like such a small thing, but Small Things Matter when it comes to programming. People notice the clatter and clank of a bad API.

And here's what this has to do with affirmations: Affirmations don't work. Research has shown that affirmations actually make the people who need them most worse off: the affirmation raises cognitive dissonance within the recipient, and instead of affirming the statement, reminds and re-affirms the negative state of mind that led to using the affirmation in the first place.

You know what does work? Reminders of past victories. That's what sports psychologists use, because they've known forever that the current-tense "I'm great!" messages don't work.

So I keep track of my past successes, even the small ones.

Date: 2010-10-14 08:23 pm (UTC)
From: [identity profile] mouser.livejournal.com
Error codes for empty lists is... odd. Error codes are for error conditions. Drop connect? Error code. Invalid query? Error code. No hits in the database? Empty list.


Back in the mid-90s I was doing some contract stuff for MS. They gave us a two inch thick book with the standards they wanted us to use. Virtually NONE of it was applicable (it was a GAME interface) and what was was contradictory. Didn't like the way they wanted you make this work? No problem! Reference a different section on the manual!

I was forbidden to talk to the MS Producer after I started to makes lists of the way Windows violated their own standards.

Date: 2010-10-14 09:52 pm (UTC)
From: [identity profile] dossy.livejournal.com
Ah, the fine differences between the empty set and the null set. Good times.

Thanks for fighting the good fight, Elf. You're awesome. :-)

Date: 2010-10-15 04:31 am (UTC)
From: [identity profile] http://users.livejournal.com/_candide_/
There are also times when you want to just iterate over a Sequence returned by some function, without having to genuflect to the non-null-ness of the return value. Because iterating over a null list/array/etc object is behaviorally-equivalent to iteratng over an empty list: do nothing in either case.

Sure, you want to allow for the special cases where you need to check if that Sequence is the null-Sequence, and take action accordingly. But doing so by turning that special case into the only case is one of the major flaws in just about every programming language. {It's certainly been the flaw in all of the ones I've used.}

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 8th, 2026 09:52 am
Powered by Dreamwidth Studios