Hello Team,
Recently I came across the guideline given for the Utility classes by
Joshua Bloch (Effective Java author).
Quick Reference -
http://www.informit.com/articles/article.aspx?p=1216151&seqNum=4

Now I have a question on the pattern we are using for the most of the
utility classes which only have the static methods, mentioning few of them
here;
- CatalogWorker.java
- CategoryWorker.java
- ProductWorker.java
- UtilMisc.java
etc.

Here in any of the class we do not have the instance methods/attributes,
and user (client) of these class may try to instantiate the object of these
class as default constructor auto applies to them, also some may tries to
extend them to add their own utility methods. We should fix this, that
means in OFBiz we do not take such kind of patch or code which will create
the instance of these classes, but we should also enforce the client of
these classes to do not instantiate and extends these classes.
We in OFBiz tries to do this in some classes like StringUtil.java by
enforcing the singleton property with the private constructor, but the
final instance of StringUtil have been used in FreeMarkerWorker.

Please let me know your thoughts on this, and if agree then I will create
Jira and submit the patch.

--
Rishi Solanki
Manager, Enterprise Software Development
HotWax Media Pvt. Ltd.
Direct: +91-9893287847
http://www.hotwaxmedia.com

Reply via email to