"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.

Search This Blog

Friday, August 22, 2003

Annoying tuple syntax: partial solution

Victor Ng writes about Python's tuple syntax for length one tuples.

Not that I use a lot of explicit length one tuples, but here's something you can do instead. Redefine the tuple function to accept non-sequences. If so, just put them in a length one tuple.

def tuple(x):
    try:
        return original.tuple(x)
    except TypeError:
        return original.tuple([x])
Then you can express an explicit length one tuple as tuple(x)

Thursday, August 21, 2003

Compound Documents

In terms of big picture ideas, open source is running out of things to copy. Here's something that hasn't been done yet.

Interesting claim about big picture ideas. I never thought of that.

I do agree that "smart clients" is a ripe area for innovation. I never used OpenDoc.

I wonder if Eclipse is a good platform for these ideas?

Wednesday, August 20, 2003

Checked Exceptions and Encapsulation

Are checked exceptions a good thing? Do they break encapsulation?

Consider an analogy.

I don't think checked exceptions are necessary. I think they can provide value.

But the cost of maintenance of static checking in Java is not worth the cost. What is my evidence?

I am more productive in Jython, which is capable of dynamically handling checked exceptions at runtime without the cost of static checking.

Let me illustrate my point with an analogy.

Consider an application command processor. The application has many functional areas. Each functional area has multiple commands that can be processed.

I can define a command abstraction and a command processor that works on the abstraction, independent of the specifics of any one command and any functional area.

In this case the commands are encapsulated and the command processor only has to be written once. New commands can be added at any time.

Now say the commands have names. And say that optionally a command can be designated as "checked", i.e. that at compile time the command processor must declare its awareness that some functional area is providing such commands.

Has encapsulation been broken? No. The problem is that named encapsulations are checked at compile time.

Is this a good thing? You decide the value.

Does it have a cost? Yes. The command processor has to be updated whenever a checked command is added to the system.

Blog Archive

About Me

Portland, Oregon, United States
I'm usually writing from my favorite location on the planet, the pacific northwest of the u.s. I write for myself only and unless otherwise specified my posts here should not be taken as representing an official position of my employer. Contact me at my gee mail account, username patrickdlogan.