Re: Method Design Help - delegates dont help

From: Tim Smith (timasmith_at_hotmail.com)
Date: 08/29/04


Date: 29 Aug 2004 15:37:36 -0700

Different services. We did try reflection but didnt gain much
benefit.

We did take a step back and looked at the overall design and realized
that the resource aquisition and usage could drop to a lower layer as
so many methods only used the resource once.

thanks

timasmith@hotmail.com (Tim Smith) wrote in message news:<a7234bb1.0408251716.45057f15@posting.google.com>...
> I have 20-50 methods (C# or Java) with the following identical content
> which I wish to write only once!
>
> public SomeObjOrVoid MethodDiffSigEachTime(SomeParams p) {
> ResouceObj resObj = null;
> ResourceTrans resTran = null;
> SomeObjOrVoid returnVal = null;
> try {
> resObj = GetResource();
> resTran = resObj.StartTrans();
> // METHOD SPECIFIC CODE GOES HERE
> } catch (Exception e) {
> LogError(e);
> } finally {
> resObj.Close();
> resTran.Close();
> }
> return returnVal;
> }
>
> I tried to use reflection but I cant pass in the method name since it
> is a helper method and if I use a hard coded string (risking runtime
> types), it loses on performance and exceptions lose a lot of
> information.
>
> There must some way to design around duplicating so much code for this
> service orientated architecture...



Relevant Pages

  • Re: Programaticly call a method from a different object?
    ... In most cases, reflection is not necessary. ... A better design removes the ... I do not answer questions on behalf of my employer. ... programmer helping programmers. ...
    (microsoft.public.dotnet.general)
  • Re: Optical Sensor (different from the 2-d sensor)
    ... Wescott Design Serviceshttp://www.wescottdesign.com ... "Applied Control Theory for Embedded Systems" gives you just what it says. ... I would try first with an LED or laser + a PIN photodiode. ... You may have more of a challenge minimizing the coupling between the transmitter and receiver with no reflection than you do with anything else. ...
    (sci.electronics.design)
  • Re: Static vs Dynamic
    ... >> of design. ... casting is necessary in order to have polymorphism in Java. ... >> You can very easily using reflection without casts. ...
    (comp.lang.lisp)
  • Re: Reflection.Cache
    ... reflection to initialize once, one object is ... point: at code design time. ... > store MemberInfos and stuff (as I did at some point because I figured the ... > - most assemblies will have reasonably small numbers of types and members ...
    (microsoft.public.dotnet.framework.performance)