Is this an anti-pattern?

anti-patterns, design-patterns, oop

Solution

You seem to be describing the Decorator pattern. In this case, the `NetworkUserManager` provides additional functionality over that provided by the `LocalUserManager`. You don't say what language you're using, but this pattern appears throughout the `java.io` package.

On the other hand, your description of `LocalUserManager.getUser()` pulling a message off the queue seems wrong -- it's backward from the way `NetWorkUserManager` works. I would see this as being a proper decorator if `LocalUserManager` accessed the database, in response to something else (perhaps a `NetworkUserManagerService`) invoking `getUser()`.

Problem

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?

Original source