Click here to Skip to main content
15,901,505 members
Home / Discussions / C#
   

C#

 
AnswerRe: Application Settings Pin
Midnight Ahri22-Jul-13 23:40
Midnight Ahri22-Jul-13 23:40 
AnswerRe: Application Settings Pin
lukeer22-Jul-13 23:09
lukeer22-Jul-13 23:09 
AnswerRe: Application Settings Pin
Midnight Ahri22-Jul-13 23:47
Midnight Ahri22-Jul-13 23:47 
GeneralRe: Application Settings Pin
Eddy Vluggen23-Jul-13 0:29
professionalEddy Vluggen23-Jul-13 0:29 
QuestionResponsive UI - WPF with Properties Pin
SynergiAios22-Jul-13 15:09
SynergiAios22-Jul-13 15:09 
AnswerRe: Responsive UI - WPF with Properties Pin
Dave Kreskowiak22-Jul-13 16:32
mveDave Kreskowiak22-Jul-13 16:32 
GeneralRe: Responsive UI - WPF with Properties Pin
SynergiAios23-Jul-13 0:18
SynergiAios23-Jul-13 0:18 
QuestionOO Design for Specifc Problem Pin
KeithF22-Jul-13 6:17
KeithF22-Jul-13 6:17 
Hi Folks,

I have a question about the best way to design / redesign my software. I have a program that uses a web services to perform certain tasks. Each task is a different set of request / response classes on the server end and a general function call from the Main Hook. EG.

C#
RequestObject req = new RequestObject("SomeVal");
ResponseObject rsp = new ResponseObject();

rsp = WebServiceHook.Method1(RequestObject); //Returns ResponseObject


Each Method takes a different request object and returns a different type of response object.

As it stands i have a class for each of these methods, Each class has a public method Process() that does the interaction. I am trying to determine the best way to group all this code together using OO techniques without sacrificing functionality. I would like just one ProcessMethod in one class that will handle the interaction with the webservice for all the different web methods. So i would only call one ProcessMethod passing a switch of sorts that would define the relevant types and uniques strings that method requires. Some Sample code below:

C#
[ComVisible(false)]
private static InfoRequest infoReq = null; //TYPES WILL DIFFER IN EACH PROCESS METHOD
[ComVisible(false)]
private static InfoResponse infoRsp = null; //TYPES WILL DIFFER IN EACH PROCESS METHOD

//PARAM TYPES WILL DIFFER IN EACH PROCESS METHOD
public static bool Process(INTERFACEREQUEST COMReq, out INTERFACERESPONSE COMRsp)
{
    bool blnReturnVal = false; //Always the same
    CInfoRsp InfoRsp = new CInfoRsp(); //TYPES WILL DIFFER IN EACH PROCESS METHOD
    CInfoReq InfoReq = (CInfoReq)COMReq; //TYPES WILL DIFFER IN EACH PROCESS METHOD

    Globals.dtStart = DateTime.Now; //Always the same
    Globals.Log(Logger.LogLevel.Minimum, Logger.LogType.APIMethodEntryPoint, "SOME TEXT HERE", "AND HERE", InfoReq.SalePointID);//Always the same - Except for the Piece of Text

    try
    {
        Globals.TheService.Url = Settings.URL; //Always the same
        infoReq = new InfoRequest(); //TYPES WILL DIFFER IN EACH PROCESS METHOD
        infoRsp = new InfoResponse(); //TYPES WILL DIFFER IN EACH PROCESS METHOD

        SetRequest(InfoReq); //Set the PHS Request Object = to Our Values Passed from the COM Component
        CallWEBServiceMethod(); //Call the  Web Service passing the appropriate arguments
        SetCOMResponseValues(InfoRsp); //Get the Info Response and Map it to Our InfoResponse Object
        COMRsp = InfoRsp; //Assign the Out Variable for COM
        blnReturnVal = AssignCOMResponse(InfoRsp);  // Set the Return Value
    }
    catch (Exception ee) //Catch any Exception that might occur along the Way
    {
        //Ensure we set the Out Variable to NULL and the return Value to False, Log this Exception Too
        COMRsp = new CInfoRsp(ee);
        blnReturnVal = false;

        Globals.Log(Logger.LogLevel.All, Logger.LogType.APIMethodException, ee.ToString() + " " + ee.InnerException);
    }
    finally
    {
        InfoRsp = null;
        InfoReq = null;
        infoReq = null;
        infoRsp = null;
        GC.Collect();
    }
}


Is what i am trying to achieve possible or am i trying to over engineer this solution. It currently works i just find every time i have to add a new web method call i clone one of the existing classes and change the types in the processMethod and anywhere else that's needed. This is quite tedious and prone to bugs.

Thanks In Advance
AnswerRe: OO Design for Specifc Problem Pin
KeithF22-Jul-13 21:41
KeithF22-Jul-13 21:41 
AnswerRe: OO Design for Specifc Problem Pin
Eddy Vluggen23-Jul-13 0:30
professionalEddy Vluggen23-Jul-13 0:30 
GeneralRe: OO Design for Specifc Problem Pin
KeithF30-Jul-13 22:49
KeithF30-Jul-13 22:49 
QuestionMicrosoft Expression Encoder with IIS Live Smooth Streaming Issue Pin
Member 1003572121-Jul-13 21:46
Member 1003572121-Jul-13 21:46 
AnswerRe: Microsoft Expression Encoder with IIS Live Smooth Streaming Issue Pin
Dave Kreskowiak22-Jul-13 1:46
mveDave Kreskowiak22-Jul-13 1:46 
QuestionGetGuiThreadInfo can not get the caret's position Pin
goldli8820-Jul-13 23:12
goldli8820-Jul-13 23:12 
QuestionHow to Create Dynamic Buttons With Students Roll No. on It From Database Pin
jackspero1820-Jul-13 1:38
jackspero1820-Jul-13 1:38 
AnswerRe: How to Create Dynamic Buttons With Students Roll No. on It From Database Pin
Garth J Lancaster20-Jul-13 2:05
professionalGarth J Lancaster20-Jul-13 2:05 
QuestionC# unmanage DLL export Pin
hijeenu19-Jul-13 10:32
hijeenu19-Jul-13 10:32 
QuestionUpdate Shorthand? Pin
eddieangel19-Jul-13 8:37
eddieangel19-Jul-13 8:37 
AnswerRe: Update Shorthand? Pin
Dave Kreskowiak19-Jul-13 9:50
mveDave Kreskowiak19-Jul-13 9:50 
AnswerRe: Update Shorthand? Pin
Abhinav S19-Jul-13 18:48
Abhinav S19-Jul-13 18:48 
AnswerRe: Update Shorthand? Pin
Jean A Brandelero22-Jul-13 3:59
Jean A Brandelero22-Jul-13 3:59 
QuestionCalling VB 6 OCX from C# EXE Pin
matinon2219-Jul-13 2:18
matinon2219-Jul-13 2:18 
AnswerRe: Calling VB 6 OCX from C# EXE Pin
Dave Kreskowiak19-Jul-13 2:21
mveDave Kreskowiak19-Jul-13 2:21 
GeneralRe: Calling VB 6 OCX from C# EXE Pin
matinon2223-Jul-13 22:18
matinon2223-Jul-13 22:18 
GeneralRe: Calling VB 6 OCX from C# EXE Pin
Dave Kreskowiak24-Jul-13 3:52
mveDave Kreskowiak24-Jul-13 3:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.