Here's the class I ended up with while building some data layer:
public class DataRequest
{
public class DataResponse
{
public DataResponse(DataRequest req) { Request = req; }
public DataRequest Request {get; set;}
// ... here go some other fields ...
}
public Response { get; set; }
public DataRequest()
{
Response = new DataResponse(this);
}
public void Execute()
{
... Get some data and fill Response object ...
}
}
I need request to be aware of response because it fills it with data; I need response to be aware of request because when i pass response to some other methods I want to have access to original request.
My question is - do you see any potential problems with this architecture, like memory leaks, etc. or is it simply a bad design idea?
Any input is highly appreciated!
Thank you, Andrey