I\'ve come across a design pattern that\'s been referred to as a \"Handler Pattern,\" but I can\'t find any real references to this pattern anywhere. It\'s basically just a
I think the goal of avoiding recompiles is much better served by a COM influenced design. What extra flexibility do you get from this:
IHandler UserHandler = ...;
Dictionary result = UserHandler.Handle(
new Dictionary{
{ "Action", "AddUser" },
{ "UserName", "Joe Bloggs" },
{ "Age", "23" } });
NewUserId = Int.Parse(result["UserId"]);
over:
IUserHandler UserHandler = ...;
AddUserResult result = UserHandler.AddUser(new AddUserArgs {
UserName = "Joe Bloggs",
Age = 23 });
NewUserId = result.UserId;
when you can extend the actions, results, and arguments:
IUserHandler UserHandler = ...;
AddUserResult2 result = UserHandler.AddUser(new AddUserArgs2 {
UserName = "Joe Bloggs",
Age = 23,
Password = "xyzzy" });
NewUserId = result.UserId;
SessionId = result.SessionId;
IUserHandler2 UserHandler2 = UserHandler as IUserHandler2;
if (UserHandler2 != null)
{
LoginUserResult loginResult = UserHandler2.LoginUser(new LoginUserArgs {
UserId = NewUserId,
SessionId = SessionId,
Password = "xyzzy" });
}