Re: method name
From: Chris Uppal (chris.uppal_at_metagnostic.REMOVE-THIS.org)
Date: 02/15/05
- Next message: Gordon Beaton: "Re: Socket Server design"
- Previous message: ash_mod2_at_hotmail.com: "Bypass proxy to access local network URLs"
- In reply to: John C. Bollinger: "Re: method name"
- Next in thread: sd: "Re: method name"
- Reply: sd: "Re: method name"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 15 Feb 2005 19:42:26 -0000
John C. Bollinger wrote:
> > Creating new object with every call in unacceptable because of limited
> > memory. The less objects the better.
>
[...]
> For what it's worth, you could put a stack-trace based solution into
> your logging mechanism instead of into every method. The logger would
> just need to look one level further down in the stack trace
As a slight improvement on that, the logging API could take an optional method
name, and the logging code would fall back to using reflection to find the
caller only if the name wasn't explicitly provided. Presumably the usual
80%/20% (or 95%/5%) rule apply to logging as much as anything else. So you
could eliminate the overhead of reflection in the few cases that took the bulk
of the execution time by passing an explicit (hand coded) method name in only
those cases.
But that's just an obvious refinement. Here's a not-at-all serious suggestion
to improve matters further:
Presumably each call to the logger will want to say something different, so the
main "message" string will be different for each call-site (at least to a good
approximation), so the logger object could contain a Map from message strings
to calling method names. It would fill that map in lazily during execution,
the first time it saw a message it didn't know about, it would use reflection
to determine the caller, and enter that into the map. Thus magically
combining the efficiency of hard-coded method names with the flexibility of
reflective lookup.
No, it's not a serious suggestion, but it would be interesting to see how far
one could get along such lines.
Any ideas for further improvements, anyone ?
-- chris
- Next message: Gordon Beaton: "Re: Socket Server design"
- Previous message: ash_mod2_at_hotmail.com: "Bypass proxy to access local network URLs"
- In reply to: John C. Bollinger: "Re: method name"
- Next in thread: sd: "Re: method name"
- Reply: sd: "Re: method name"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|