What would you do?



Hi,

Let say I have a method in a helper class that is used throughout my java
project. This method changes a string value to empty if it has a null value.

public final String emptyStringIfNull(String a)
{
return a==null?"":a;
}

Would it be better to make this mathod to be static and synchronized?
On one hand, I am worry about the trade off in the slowdown caused by
synchronization..
On the other, I find it a sore to always to instantiate the helper class.

What are your views on it?

Regards,
James Yong


.



Relevant Pages

  • Re: What would you do?
    ... This method changes a string value to empty if it has a null value. ... >synchronization.. ... I find it a sore to always to instantiate the helper class. ...
    (comp.lang.java.programmer)
  • Re: What would you do?
    ... This method changes a string value to empty if it has a null value. ... If you have already implemented the method as an instance method, then I'd leave it that way. ... If you decide to make it static anyway then be sure to change all invocations to use the static invocation syntax ); ...
    (comp.lang.java.programmer)
  • Re: Remove scriptlets from JSP
    ... > In my JSP i have some scriptet code that defines the method ... > display(ArrayList a, String s) ... you could just import the helper class and still use an expression ... enough, you might be able to replace it with Struts logic tags, such as ...
    (comp.lang.java.programmer)
  • Re: DragEventArgs and GetDataPresent with abstract base class
    ... if it's a string description of the data, ... > The drag source provides information about the available types of ... You always pass the helper class across during your ... The control is either a PictureControl or a ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: C++ strings
    ... A BSTR is a pointer to an OLE string (also known as a Unicode or wide char ... A char[] is an array of 8-bit characters (often referred to as an ASCI ... CComBSTR is helper class for dealing with BSTR's that comes from Microsoft's ...
    (microsoft.public.vc.language)