You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Foo Shyn Chung <ip...@gmail.com> on 2012/01/19 05:49:39 UTC

Question on services methods

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

Re: Question on services methods

Posted by Foo Shyn Chung <ip...@gmail.com>.
Got it. Thanx for the explaination. =)

On Sun, Jan 29, 2012 at 3:44 PM, David E Jones <de...@me.com> 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
> >
>

Re: Question on services methods

Posted by David E Jones <de...@me.com>.
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
>

Re: Question on services methods

Posted by BJ Freeman <bj...@free-man.net>.
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
>