RE: [aus-dotnet] Whidbey Beta2 and the "Go Live"


    [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
    • From: Mina Casiou
    • Subject: RE: [aus-dotnet] Whidbey Beta2 and the "Go Live"
    • Date: Thu, 02 Dec 2004 14:25:20 +1100

    
    
    
    I'll have to dwell on this a little.
    It just means I'll have to wrap the whole call in an object of some sort -
    String etc. to make sure I've got an object to call the ToString() method
    on.
    
    For example,
    You'd often log things like:
          myEvent.Raise(eventSource, eventPublishLogLevel, "Hello
    instrumentation world" &  obj.serialize() & "some other stuff etc.")
    I don't want the:
          "Hello instrumentation world" &  obj.serialize() & "some other stuff
    etc."
    to get evaluated just yet. Wrapping this up in an object would not solve
    this problem at the moment.
    Even using a StringBuilder would require an object to be created etc.
    
    RE:
    Or perhaps you could use Delegates. Even better with C# 2.0 and anonymous
    delegates, which give you more room to play similar to Smalltalk blocks
    
    I don't know how these things would benefit off the top of my head. (I've
    never used Smalltalk either.).
    I'll look into the anonymous delegates & see if anything good pops out at
    me, though they're not slated to be in VB.NET AFAIK.
    
    The Lazy Evaluation option still looks good to me, but I'll jump at
    anything that will satisfy the original requirements:
    1)Run as fast as possible - i.e. about as fast as the Calling 'If'
    statement will run
    2)Minimise the amount of work the logging client needs to do.
    
    Another option is to have a conditional attribute that is compiled in and
    out on a Config file change!
    At one stage, I had 2 builds (well 3 or 4 actually...but not relevant). A
    standard Release Build, and an OptimisedLogging build. The optimised
    logging build had the Log Messages for one class of log statements compiled
    out. This particular build ripped along, as only errors were ever logged.
    Not really any good for a production system though, where you'd need to
    turn logging up & down on the fly etc.
    
    I looked around for solutions & eventually bit the bullet & changed all of
    the logging code throughout the codebase (YUUUCKY!!!).
    I'll do anything to have it back the way it was.
    At least the interception will cut out 2 lines of code for every function
    that currently exists. Thanks.
    
    ps. Thanks a MILLION for the RealProxy thinggy...That rings a bell. There
    was a sample or something I downloaded once (but since lost!). Now I've got
    the name, it shouldn't take long to find. Thanks again.
    Object you want to intercept should extend MarshalByRefObject
    
    Wrap your marshalbyref object in a subclass of
    System.Runtime.Remoting.Proxies.RealProxy.
    
    Read up on RealProxy, thats where you can intercept method calls to the
    marshalbyref object.
    
    Cheers
    Minas Casiou
    Information Systems Architect, Senior Consultant
    CSC Australia – Financial Services - Enterprise Business Solutions
    26 Talavera Road
    Macquarie Park NSW
    2113 Australia
    Ph: (02) 9034 3338
    Mob: 0412 343 069
    email: mcasiou@xxxxxxxxxx
    ----------------------------------------------------------------------------------------
    
    This is a PRIVATE message. If you are not the intended recipient, please
    delete without copying and kindly advise us by e-mail of the mistake in
    delivery. NOTE: Regardless of content, this e-mail shall not operate to
    bind CSC to any order or other contract unless pursuant to explicit written
    agreement or government initiative expressly permitting the use of e-mail
    for such purpose.
    ----------------------------------------------------------------------------------------
    
    
    
    
    |---------+--------------------------->
    |         |           Sean Malloy     |
    |         |           <Sean@xxxxxxxxxx|
    |         |           m.au>           |
    |         |           Sent by:        |
    |         |           dotnet-owner@sta|
    |         |           nski.com        |
    |         |                           |
    |         |                           |
    |         |           02/12/2004 12:53|
    |         |           PM              |
    |         |           Please respond  |
    |         |           to dotnet       |
    |         |                           |
    |---------+--------------------------->
      >-------------------------------------------------------------------------------------------------------------------------------|
      |                                                                                                                               |
      |        To:      "'dotnet@xxxxxxxxxxx'" <dotnet@xxxxxxxxxxx>                                                                   |
      |        cc:                                                                                                                    |
      |        Subject: RE: [aus-dotnet] Whidbey Beta2 and the "Go Live"                                                              |
      >-------------------------------------------------------------------------------------------------------------------------------|
    
    
    
    
    > Thanks for the idea etc.
    > Serialize is not the only type of processing I do on logging
    > a message etc.
    > Think about it. Basically any string operation you do,
    > constants and all,
    > can be done there.
    > The point it to make the calling logging code simpler, not
    > more complex and
    > to have less of it.
    >
    > I don't know of a nice generic way to do what you've shown.
    > Again, the goal
    > is simple client code. ==> Simpler than what it currently is.
    >
    > I'm open to any ideas.
    > Thanks
    
    IMO, custom domain objects for handling your logging requirements is a
    simpler solution than having some Lazy Evaluation attributes tacked on to
    the runtime.
    
    Alternatively you could implement ToString() on your domain object, which
    internally just returns SerializeToXML(), and use a single generic Raise
    function:
    
    public function Raise (myEventSource as EventSource, eventPublishLogLevel
        as Integer, msgToLog as Object)
        If (eventPublishLogLevel > applicationLogLevel) And
    
    EventSource.Application.IsEnabledForType(GetType(TraceMessageEvent))
    Then
               actualLog(myEventSource, eventPublishLogLevel,
    msgToLog.ToString())
        End If
    end function
    
    That way you could pass in a String, or a custom object which overrides
    ToString()
    
    Or perhaps you could use Delegates. Even better with C# 2.0 and anonymous
    delegates, which give you more room to play similar to Smalltalk blocks
    
    Either way, the use of attributes to add functionality like lazy
    initialisation or execution seems abhorrent to me. I guess I must be the
    only person who feels this way.
    
    Regards,
    
    Sean
    _________________
    You are a part of the Australian "dotnet" mailing list.
    To unsubscribe send "unsubscribe dotnet" or to re-subscribe send "subscribe
    dotnet Your Name" in the body of the email to: imailsrv@xxxxxxxxxxx
    List managed by: http://www.stanski.com
    
    b�����h~���bjwh�w�����x%������&ޱ�{.n�������������&ޱ����y����g���n�r���[h�f����֧�H��b����u�����0�֧�H��



    (Click here for more information on the aus-dotnet mailling list)