• Post Reply Bookmark Topic Watch Topic
  • New Topic

How would I design this?  RSS feed

 
Raghu Devatha
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am not sure whether I am asking for help at the right place. Please pardon me if I am not.

Suppose I have two different methods m1 and m2 both implementing different interfaces ( in completely different classes) which perform their task independenlty. At certain point of time I get a situation where I am asked to do what m1 and m2 combine would do. What would be the ideal design, writing a new implementaion or would modify anyone of those.

Please redirect me if I am at wrong place.
Thanks
Raghu
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand the question completely, but to me it sounds like you could write a method that invokes the other two. That way you don't go messing around with proven code, and you don't have to worry about having duplicate code existing.
 
Raghu Devatha
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Joe Thanks a lot for your reply. You understood my problem. I really don't want mess up the existing proven code of mine.

Was my initial design for those two methods wrong, I am really upset because I thought they would be always independent, will the case of mine arise for others or just in my case of my poor initial design.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have no way of answering that without knowing what's actually being done.

Composition is not a Bad Thing.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!