P
puzzlecracker
What I currently have and request a suggestion to modularize it
public sealed class Connection: BaseConnection{
//I have to process about 30 events
public event Handler1=handler1;
public event Handler2=handler2;
public event Handler3=handler3;
public event Handler4=handler4;
//I have to process about 30 service calls
public void Service1(){}
public void Service2(){}
public void Service3(){}
private void OnHandler1(Request aRequest)
{
if (handler1 != null)
handler1(aRequest);
}
private void OnHandler2(Request aRequest)
{
if (handler2 != null)
handler2(aRequest);
}
private void onHandler3(Request aRequest)
{
if (handler3 != null)
handler3(aRequest);
}
//and so on
protected override Dispatch(Event e){ // based on event, I process
and call onHandlers}
// more functions to process the events.
}
In separate file, I define all those delegates. I give client the dll
containing this class and some enumerations, and declarations.
So, the client of my api would use it in this way
Connection conn=new Connection();
conn.handler1+=...
conn.handler2+=...
//etc
conn.Connect();
conn.Service1();
conn.Listen();
conn.Destroy();
The issue is that I implement services and event handling in just one
class Connection, taking some implementation from Base connection,
resulting in over 4K lines of code. Any suggestion to improve the
design?
Thanks
public sealed class Connection: BaseConnection{
//I have to process about 30 events
public event Handler1=handler1;
public event Handler2=handler2;
public event Handler3=handler3;
public event Handler4=handler4;
//I have to process about 30 service calls
public void Service1(){}
public void Service2(){}
public void Service3(){}
private void OnHandler1(Request aRequest)
{
if (handler1 != null)
handler1(aRequest);
}
private void OnHandler2(Request aRequest)
{
if (handler2 != null)
handler2(aRequest);
}
private void onHandler3(Request aRequest)
{
if (handler3 != null)
handler3(aRequest);
}
//and so on
protected override Dispatch(Event e){ // based on event, I process
and call onHandlers}
// more functions to process the events.
}
In separate file, I define all those delegates. I give client the dll
containing this class and some enumerations, and declarations.
So, the client of my api would use it in this way
Connection conn=new Connection();
conn.handler1+=...
conn.handler2+=...
//etc
conn.Connect();
conn.Service1();
conn.Listen();
conn.Destroy();
The issue is that I implement services and event handling in just one
class Connection, taking some implementation from Base connection,
resulting in over 4K lines of code. Any suggestion to improve the
design?
Thanks