Which pattern for this scenario ?
Hi all,
I have an EJB which connects to an external system (written in Perl) using plain HttpConnections and posting HTML content.
I would like to centralize this access using a design pattern.
Which pattern is would fit this scenario ?
I wonder if I should use the Adapter pattern or the Bridge Pattern.
What do you say to it ?
Thanks
Francesco
# 1
why a pattern? don't automatically assume a design pattern will solve a problem, and don't try to make a pattern fit a problem. all you want is a class that represents this external system, that your client code can talk to, and which deals directly with the external resource. you could call it an adapter if you like
# 2
Thanks for your reply.
Well I forgot to mention, it's only for an University essay. It's more theory then practice :-)
I have been given this scenario and I have to choose which pattern is best suited for it.
For example, if we imagine that the web application written in Perl will be migrated to JSP in the future, what pattern will isolate better the change in your opinion ?
Tks
Francesco
# 3
I'd kind-of guessed it was uni work :-)
in all honesty, I wouldn't even approach the problem from a patterns perspective. all I see is a subsystem I don't want to deal with directly, so I define an interface to hide it behind. could argue that it's an Adapter, since it's taking the Http interface and abstracting away from it, to a java one. on the other hand, since mucking around with Http in java isn't exactly straight-forward, you're defining a more simple interface, so it could be considered a facade. which do you think is closer?
most people, once au fait with design patterns, think less in terms of those patterns, and more in terms of what OO principles to apply. score some extra credit by writing a passage about how design patterns are not prescriptive, and that many coders lift ideas about encapsulation and separation from patterns, rather than use the pattern exactly as described.
# 4
Quasi-academic IT research should be viewed with contempt.
The subjective, haphazard censorship of content practised by the Sun Forum Modertors is a dangerous example of how an organization can control ideas and attempt to govern intellectual capital.
The founding fathers of the American constitution must be turning in their graves.
Good luck everyone in the coming times. They will be tough.
Best Regards,
Grand Master M.W. Champion of Truth from the East
Ancient Moabite Temple #3