On Thu, Jun 29, 2000 at 02:35:56PM +0200, Regis Koenig wrote:
> Sean Legassick wrote:
> > These sound like an excellent set of improvements - perhaps you could
> > post a URL to your diffs, or failing that post them here.
>
> The files are available at
> http://www.chez.com/rkoenig/turbine_mail.tgz
>
> Some problems left ... The WebMacroEmail stuff may be better in the
> ...webmacro.util package.
Looks good - though it would be preferable if you could provide diffs
for patches to existing files. Also, yes - WebMacroEmail is in
turbine.util.webmacro now so it should stay there.
> The functions setFrom(), addTo() ... return void. It would be better to
> return an Email, so one can do something like
>
> mail.setFrom("[EMAIL PROTECTED]").addTo("[EMAIL PROTECTED]");
Yep, indeed you should add this.
> The problem comes from the subclasses. It is not natural to write
>
> ((HtmlEmail)mail.setFrom(...)).setHtmlMsg(...). Any idea to avoid this ?
Not as such. Unfortunately Java don't allow you to override methods and
have them return a subclass of the superclass method's return type.
There's no reason it shouldn't allow this, you're not breaking the
contract of the baseclass method signature (you can do it in C++).
But anyway as you can't do it that way there are three options I can see:
a) keep things as is and insist that if the class user wants to use the
chaining idiom they have to use subclass methods first, so the above
example would be:
mail.setHtmlMsg(...).setFrom(...)
It's not a very nice requirement of the API.
b) the other choice is to break the OO a bit and have a setHtmlMsg
method in the baseclass which does nothing/throws an exception.
Also not very nice.
c) similar to (b) break the OO and subsume all the functionality into
the baseclass, perhaps having HtmlEmail be a helper class rather than a
subclass.
--
Sean Legassick
[EMAIL PROTECTED]
homo sum: humani nihil a me alienum puto
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]