Curt, good points!

On Mon, 10 Jan 2005, Curt Arnold wrote:

|
| > When logging an event, we should not build two objects
| > (LoggingEventBuilder+LoggingEvent) instead of the current one
| > (LoggingEvent).
| >
|
| In that high volume use and reentrant code, it might be best to
| continue to use a special constructor, but that might be made package
| private so it can only be used within log4j.

I don't see the reason for this: String has both a constructor, and a
Builder. Why couldn't LoggingEvent also have this? I do agree with Ceki
here - two objects should most definately not be needed when simply
wanting to make a new LoggingEvent object. But if you -have- to do it
incrementally, then a utiltiy-style Builder is nice. Another approach is
of course simply to set temp variables (its only four, isn't it?), and
finally, when you actually want to instantiate the LoggingEvent, then do
so with the variables - the Builder is really very very simple.

Rip away all the setters, incl. the private ones, make it totally
immutable (it's just a immutable "value object"), letting it have -one-
constructor taking all the arguments, take away all synch penalties on
construction, and optionally also make a utility Builder. Nice.

The possibility for reusing all System.hashCodes within one millisecond
seems to me -extremely- close to zero: To have this happen, one would need
GC inbetween the instantiations, and having GC take -under- one
millisecond, in addition to hitting the same "address" on the two
instantiations, just seems plainly impossible. If you also check for
message equality (potentially by storing the String's System.hashCode in
the same way as the LoggingEvent itself), and equality of level and
logger's String-representation of category, you'd -really- be pretty
certain that an "equal()" LoggingEvent really is the same LoggingEvent.
The last one might not be necessary.

Endre





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to