Search code examples
c#remotingclass-librarycode-organization

C# Remoting classes organization


I'm developing a Remoting classes library so that I can keep database interaction and business object on the server and not on clients.

I'd like to be able to return my own objects to the clients so that they can interact with them through the server itself.

For example (semi-pseudocode):

Server

class Database { ... }
class Utility
{
  public User getUser(username)
  {
     return new User(username);
  }
}
class User
{
  public string[] getPerms()
  {
    return Database.query("select * from permission where user = " + this.username);
  }
}

Client

Utility utility = (Utility)getRemotingClass("Utility");
User user = Utility.getUser("admin");
string[] perms = user.getPerms();

How can I organize my classes/namespaces? I'm particularly wondering about class references and scalability of my system.

Any kind of criticism/suggestion is really appreciated.


Solution

  • I don't mean to beat a drum, but you might want to look into WCF. Remoting is very chatty and the real support for maintaining clean interfaces by .Net is being done through WCF and message passing, as opposed to full object state management through remoting.

    What it sounds like you are doing is developing a middle tier for management of the database connections. Just make sure you don't end up redeveloping the interface to SQL server.