Separating responsibilities with dependencies on a central “producer” object

Say you have an object that has a kind of connection to a platform or whatever. For example, an object that is used to connect to a distant web site where you can control various robots.

The producer object is used to get a dozens of instances through the connection representing these robots. These objects are dependent on the first object in that any operations are required to go through the connection. So any local code would just be putting calls through the producer object.

robots <-> connection <-> robotObjects

The originating object could have a certain number of utility methods for each of these instances that would relay changes back. However, that could turn it into a "god" class of some kind which does everything.

How would you go about separating responsibilities in a case like this ?

P.S: Feel free to suggest a better title.


What you describe sounds very similar to the proxy pattern:

  • There is a Robot interface.
  • The server controls the real robots through a concrete implementation, say RealRobot.
  • The client has a Connection object which can return proxies that implement the Robot interface but forward calls through the connection to the real robots.

The Connection object itself would provide only basic communication methods (for eg. to send and receive data) and not contain any of the "utility methods" that you describe. The proxy implementation would make use of these communication methods to relay calls to the server.

Here's an example:

Shared interface:

public interface Robot {
  void move(...);

Server implementation:

public class RealRobot implements Robot { ... }

Client library:

public class Connection {
  public Robot getRobot(int id) {
    return new RobotProxy(id, this);

  // ...
  // methods for sending and receiving data
  // ...

public class RobotProxy implements Robot {
  private final int id;
  private final Connection conn;

  public RobotProxy(int id, Connection conn) { = id;
    this.conn = conn;

  public void move(...) {
    conn.send("move", id, ...);

Need Your Help

Sencha Touch 2: Trying to add a list to a panel

extjs sencha-touch-2

I have a panel which consists of a toolbar and tabs. On each tab there should be a list and a button. I believe I have this set up correctly except for the list, which I am trying to add as follows:

Draw td by Smarty Templates?

php smarty

i have categories and subs and i want draw every category with sub in td. i write this code but it draw all category with sub in one td. what is the problem? thank you

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.