In answer to your other question (name of the pattern), it's called delegation.
Whether its a "good" thing or not depends entirely on where/how you use it. A good use would be to abstract away dealing directly with other dependencies (so for example centralising and hiding use of the inputManager
via your Game
). However a bad use would be simply exposing all of the inputManager
's properties via a separate class (say your Game
).
Your aim should be to have each class have a well defined role within your system and collaborate with other objects to perform its responsibilities. In doing this you want to create layers of abstraction that help reduce the amount of dependence the objects have on each other. So with that in mind, I'd say if you were delegating a lot of properties through, I'd start thinking it was a bit of a code smell (since you're mixing responsibilities of the classes).
As a concrete example, I'd say you should have something more like this:
class Game
{
Point getPlayerTarget()
{
return new Point(inputManager.getMouseX(), inputManager.getMouseY());
}
}
In other words, the Game
is responsible for knowing what the player is targeting, but not for the exact x,y coordinates of where the mouse is. This keeps your code nice & clean and allows you to do things like change underlying dependencies (say the method of input in your example), without having to change masses of code (i.e. your Game
class wouldn't need to change its interface).
Of course my example removes the direct delegation, which implies that I think its a bad thing... There will, however, be times where it's a good thing. Extending my example above, if there were other methods on your inputManager
that other classes might need exactly as is, then it probably does make sense for the Game
to delegate these through directly rather than having higher up dependencies need to sometimes talk to Game
and sometimes talk to InputManager
. Hope that makes sense.