Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

design pattern question

 
imran quazi
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
imran quazi
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I used strategy pattern and its working nicely.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic