Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this an anti-pattern?

The situation is this: You have two classes that both implement the same interface and both classes work together to complete some business process.

For example networkUserManager and localUserManager implement IUserManager which has a method getUser(). networkUserManager.getUser() puts a request to get a User on the queue and returns the reply. localUserManager.getUser() gets a request off the queue, finds the user information in some database, and then replies with the user data.

When I saw something similar to this being done, I couldn't help but wonder if this was bad design. Is this bad design and if not what is an example where doing something like this would be a good idea?

like image 322
insipid Avatar asked Jan 20 '10 22:01

insipid


1 Answers

That smells pretty bad to me. Different classes may have methods with the same name, of course, but if they are both implementing the same interface, then there is an assumption that they will be doing the same thing. Here they are doing opposite things!

Perhaps it's a lack of imagination on my part, but I cannot fathom why that would ever be a good idea.

like image 128
Jeffrey L Whitledge Avatar answered Nov 05 '22 19:11

Jeffrey L Whitledge