On Wed, 9 Jan 2002 02:41, Updike, Clark wrote: > Can you explain a bit about why your project considers static methods to be > bad design and what you mean by "part of a service" (i.e. do mean > generically as a capability that an object provides, or a service in the > sense that it is stateless but offered by an instance, or something > different altogether).
Well our project does not consider statics harmful as such if they do not rely on facilities other than those passed in parameters (ie completely stateless). However logging requires some "context" information which is impossible for the static method to determine. You can guess the "context" by forcing logger objects to always use a default logging namespace however this will cause issues when there is multiple components in the JVM who may potentially using different namespaces or whatever. Hence the general rule is that if a service is really stateless then it is fine to be completely static - however if it has state of any sort - including context stuff such as a logger etc then it should be an instance. > I think the static approach is used often to save object instantiation. Is > the "service" in your paradigm implemented in some way such that it is > accessed without instantiating an instance of the service each time or is > the overhead of object creation considered worthwhile to avoid 'bad > design'? Im not sure what you mean. In Avalon (as in most component based toolkits) you create a service once at the start of your application and then place it in a service directory. In Avalon the service directory is the ComponentManager, in J2EE it is JNDI, in the servlet spec it is the Servlet Context etc. So you only create the object once and this shouldn't be too much of a cost -- Cheers, Pete ------------------------------------------------------- "I would like to take you seriously but to do so would affront your intelligence" -William F. Buckley, JR ------------------------------------------------------- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>