On 09/12/2010 09:30, Millies, Sebastian wrote:
-----Original Message-----
From: Simon Nash [mailto:[email protected]]
Sent: Thursday, December 09, 2010 10:20 AM
To: [email protected]
Subject: Re: Elementary question about Scopes
Millies, Sebastian wrote:
Yes, I see the point about callbacks.
With regard to the other, cosmetic differences, what you regard as
ugly, I
regard as good programming practice. To me, instance variables
represent the
state of an object, in particular mutable state. If there is no such
state,
I find it much clearer to pass parameters as method arguments rather
than
to store them in instance variables.
With STATELESS scope, the object instance == the individual service
request.
Therefore it is completely appropriate to store data relating only to
the
individual request as instance variables of this object.
Simon
[snip]
I believe it's only a matter of taste. After all, all the "data relating
only to the individual request" already come in as service method parameters.
As different methods have different parameter sets, copying the top-level
method parameters to instance variables makes for code which I find hard to
read, because in methods lower in the call hierarchy, I cannot easily see
which part of that "request state" is really relevant.
In contrast, I can see that immediately from a method signature, when all
relevant parameters are threaded through the call tree.
-- Sebastian
Sebastian,
I regard a decision to make all component implementations COMPOSITE scope by default to be a strange
one.
In doing so, you are EITHER
- accepting that you will limit your code to not using any mutable instance
variables
OR
- taking on the burden of providing appropriate synchronization for any mutable
instance variables
Either seems unnatural/unnecessary UNLESS you know for sure that your implementation has
initialization/destruction steps that will take a considerable time to execute.
It seems to me that COMPOSITE scope is an evil to be approached only when absolutely required, such
as when there is initialization that takes forever to complete.
However, you are free to choose ;-)
Yours, Mike.