|
Hi all,
This may sounds stupid, please spare me =p. I've noticed that methods in the Services class are written as static and i'd come across a discussion thread that talked about why it is so. (http://osdir.com/ml/user.ofbiz.apache.org/2009-09/msg00284.html) However, there are times that a method in the Service class is either too long or there are common codes between 2 methods that i would like to refactor them into using a new method. Since all the methods need to be static, so the new smaller methods that i'm creating will be in static as well. I wonder whether this would cause the thread-safe issue concerning the static state of the methods? Thanx FooShyn |
|
short answer the origial design was to have individual routines so it
could be reused. That got lost with new committers. I dont use the SVN since I have re-factored ofbiz. Foo Shyn Chung sent the following on 1/18/2012 8:49 PM: > Hi all, > > This may sounds stupid, please spare me =p. > > I've noticed that methods in the Services class are written as static and > i'd come across a discussion thread that talked about why it is so. > (http://osdir.com/ml/user.ofbiz.apache.org/2009-09/msg00284.html) > > However, there are times that a method in the Service class is either too > long or there are common codes between 2 methods that i would like to > refactor them into using a new method. Since all the methods need to be > static, so the new smaller methods that i'm creating will be in static as > well. I wonder whether this would cause the thread-safe issue concerning > the static state of the methods? > > Thanx > FooShyn > |
|
In reply to this post by Foo Shyn Chung
Thread safety issues come from the use of static fields in a class, not static methods. -David Foo Shyn Chung wrote: > Hi all, > > This may sounds stupid, please spare me =p. > > I've noticed that methods in the Services class are written as static and > i'd come across a discussion thread that talked about why it is so. > (http://osdir.com/ml/user.ofbiz.apache.org/2009-09/msg00284.html) > > However, there are times that a method in the Service class is either too > long or there are common codes between 2 methods that i would like to > refactor them into using a new method. Since all the methods need to be > static, so the new smaller methods that i'm creating will be in static as > well. I wonder whether this would cause the thread-safe issue concerning > the static state of the methods? > > Thanx > FooShyn > |
|
Got it. Thanx for the explaination. =)
On Sun, Jan 29, 2012 at 3:44 PM, David E Jones <[hidden email]> wrote: > > Thread safety issues come from the use of static fields in a class, not > static methods. > > -David > > > Foo Shyn Chung wrote: > > Hi all, > > > > This may sounds stupid, please spare me =p. > > > > I've noticed that methods in the Services class are written as static and > > i'd come across a discussion thread that talked about why it is so. > > (http://osdir.com/ml/user.ofbiz.apache.org/2009-09/msg00284.html) > > > > However, there are times that a method in the Service class is either too > > long or there are common codes between 2 methods that i would like to > > refactor them into using a new method. Since all the methods need to be > > static, so the new smaller methods that i'm creating will be in static as > > well. I wonder whether this would cause the thread-safe issue concerning > > the static state of the methods? > > > > Thanx > > FooShyn > > > |
| Free forum by Nabble | Edit this page |
