You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Jeremias Maerki <de...@greenmail.ch> on 2002/11/06 16:18:40 UTC

interface instead of implementation

Fellow FOP developers,

would you mind using the interface instead of the implementation where
possible? Map instead of HashMap, List instead of ArrayList. I've seen
this habit in a number of places and not only by Keiron! I've made it a
habit to follow this pattern:

import java.util.List;

[..]

private List myvalues = new java.util.ArrayList();

ArrayList never gets imported. That makes it easier to switch between
implementation, for example if you have to switch between the
unsynchronized ArrayList and the synchronized Vector. The decision which
implementation to take should happen at one place in the code, not at
many places. For Map there exist new implementations in Jakarta Commons
Collections, for example. A method that takes List parameters (instead
of ArrayList) is more universal.

Thank you all!

On 6 Nov 2002 15:07:04 -0000 keiron wrote:
>   +
>   +    /**
>   +     * Traits for this area stored in a HashMap
>   +     */
>   +    protected HashMap props = null;

Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: interface instead of implementation

Posted by Jeremias Maerki <de...@greenmail.ch>.
On Wed, 6 Nov 2002 16:25:24 +0100 Bertrand Delacretaz wrote:
> On Wednesday 06 November 2002 16:18, Jeremias Maerki wrote:
> >. . .
> > would you mind using the interface instead of the implementation where
> > possible? 
> 
> big +1.

Thanks for your support.

> The only drawback is when you need to clone Collections, but the benefits far 
> outweigh this I think.

I agree.

> Maybe a minimal "best practices" or "style guide" document for developers 
> would be nice, I don't think there is one already?

We've discussed coding style issues a few weeks ago. But we still
haven't hammered anything down, I think. Still on my todo list. I'll
have time for this in two or three weeks.

Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: interface instead of implementation

Posted by Jeremias Maerki <de...@greenmail.ch>.
Sorry, Keiron, for explicitly mentioning you. I was just working in the
maint branch seeing all those ArrayLists (former Vectors) and HashMaps
(former Hashtables) that are creeping through all the code. And then
your CVS commit came... I know I can be an elephant in a porcelaine
store sometimes. Sorry.

Anyway, I intend to overtake you with style error fixing soon. :-)

On 06 Nov 2002 16:43:06 +0100 Keiron Liddle wrote:
> Since I have removed over 3000 style errors you give me a bit of slack!!
> :)


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: interface instead of implementation

Posted by Keiron Liddle <ke...@aftexsw.com>.
On Wed, 2002-11-06 at 16:18, Jeremias Maerki wrote:
> Fellow FOP developers,
> 
> would you mind using the interface instead of the implementation where
> possible? Map instead of HashMap, List instead of ArrayList. I've seen
> this habit in a number of places and not only by Keiron! I've made it a
> habit to follow this pattern:

I agree, I can be a bit lazy sometimes.

Since I have removed over 3000 style errors you give me a bit of slack!!
:)

Keiron.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: interface instead of implementation

Posted by Oleg Tkachenko <ol...@multiconn.com>.
Bertrand Delacretaz wrote:

> Maybe a minimal "best practices" or "style guide" document for developers
> would be nice, I don't think there is one already?

Some time ago Jeremias has promised us that already :)

-- 
Oleg Tkachenko
eXperanto team
Multiconn Technologies, Israel


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: interface instead of implementation

Posted by Bertrand Delacretaz <bd...@codeconsult.ch>.
On Wednesday 06 November 2002 16:18, Jeremias Maerki wrote:
>. . .
> would you mind using the interface instead of the implementation where
> possible? 

big +1.
The only drawback is when you need to clone Collections, but the benefits far 
outweigh this I think.

Maybe a minimal "best practices" or "style guide" document for developers 
would be nice, I don't think there is one already?

-Bertrand

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: interface instead of implementation

Posted by "Peter B. West" <pb...@powerup.com.au>.
Jeremias,

I have no objection at all, as long as it costs nothing.  It is free, 
isn't it?

Peter

Jeremias Maerki wrote:
> Fellow FOP developers,
> 
> would you mind using the interface instead of the implementation where
> possible? Map instead of HashMap, List instead of ArrayList. I've seen
> this habit in a number of places and not only by Keiron! I've made it a
> habit to follow this pattern
...

-- 
Peter B. West  pbwest@powerup.com.au  http://www.powerup.com.au/~pbwest/
"Lord, to whom shall we go?"


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org