File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes design pattern question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "design pattern question" Watch "design pattern question" New topic
Author

design pattern question

imran quazi
Greenhorn

Joined: Dec 01, 2006
Posts: 18
A scenario occurred like this:
3 classes: Bat, Eat, Fat. When Bat is instantiated only Bat related methods are called. When Eat is instantiated Eat+ Bat related methods are called. When Fat is instantiated Fat+Eat+Bat (means all) methods are called.

Bat & Eat are language specific & there are nine languages. So, nine Bat & nine Eat. But, Fat is not language specific, there's only one Fat. Now, the question is how it can be designed so that when suppose french is passed as language parameter Bat_fr+Eat_fr+Fat specific methods will be called.

I thought of making Bat as interface which will be extended by Eat interface & which will be implemented by Fat. Don't know if it is ok.

Kindly guide me.

Regards,
Imran
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by imran quazi:
...the question is how it can be designed so that when suppose french is passed as language parameter Bat_fr+Eat_fr+Fat specific methods will be called...

Have you looked at the strategy pattern?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
imran quazi
Greenhorn

Joined: Dec 01, 2006
Posts: 18
Thanks,

I used strategy pattern and its working nicely.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: design pattern question
 
Similar Threads
Inheritance and Polymorphism
Where do static variables & methods live?
abstract class and static methods qs
What is an interface?
interfaces Vs abstract classes