Now blogging at diego's weblog. See you over there!

when abstractions don't work

As I've been reimplementing the functionality provided by the JavaMail API for spaces, I've realized that JavaMail has one important flaw: its level of abstraction. That is, it's too abstract.

Theoretically, from a design point of view, the JavaMail API makes sense, you've got Folders, Sessions, Transports, and so on, with the appropriate subclasses. But then...

POP3 and IMAP4 are for receiving, but they are very different. IMAP essentially provides a server-side back-end for a mail client, while POP provides only transient storage between sender and receiver (although you can use it for long-term storage, it's not really designed for it). IMAP supports folder hierarchies. POP doesn't. IMAP supports searching and understand the structures of RFC822 messages. POP can tell you the size of a message and a server UID, or you have to get the entire message. IMAP lets you subscribe to a folder. POP doesn't even know that folders exist.

And then, of course, SMTP is for sending, rather than receiving.

Similar "impedances" could be identified, for example, for NNTP, something else that is sometimes implemented with JavaMail interfaces.

In the end, the main thing that these things have in common is that they: a) deal with Mime Messages (or RFC822 plaintext), b) they require connection, disconnection, and possibly login. Everything else is different.

So, does it really make sense to fit these wildly different systems under the same interface?

Having used JavaMail on the server side, I understand that there is an advantage to its abstraction, and it's relatively easy to use. But when you need it to build the functionality of a full email client on top of it, the abstractions start to become unwieldy.

That said, I don't think it was intended for that! (or was it?) I think it was something that provided basic mail functionality to applications that needed it, but where it wasn't central. Maybe I just got carried away!

Talk about rants that come full circle. So this was a feature of the design then, and not a flaw? Depends on how you look at it...

Yeah, too much coffee, I know... :-)

Posted by diego on April 14 2003 at 10:54 PM

Copyright © Diego Doval 2002-2011.
Powered by
Movable Type 4.37