Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Pattern: converters. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Pattern: converters." Watch "Pattern: converters." New topic
Author

Pattern: converters.

surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Hello Partners!
Please help with architectural decision.
I have 2 converters:

How to abstract from concrete converters to add new implementations in future?
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1505
    
    5

Hi surlac,

I'm not sure if I got your question properly, but (especially in case of converters), I would use Abstract-Factory pattern - that is - an abstract factory - which will create a concrete factory (XMLConverterFactory or JSONConverterFactory) which will further create relevant concrete objects (XMLConverter or JSONConverter).

To make it even better, I would use an interface for converter (which will be implemented by all converters), an interface for node and so on.

I hope this helps.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Anayonkar Shivalkar wrote:
I'm not sure if I got your question properly, but (especially in case of converters), I would use Abstract-Factory pattern

You've got it right. Thanks for your advice.
So it can be used to load additional concrete converters from external jars, right? Separate from abstract factory jar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pattern: converters.