tag:blogger.com,1999:blog-22587889.post1993159430739847100..comments2024-02-11T13:21:47.930+05:30Comments on Ruminations of a Programmer: Design Tip: Localize your Object Creation LogicAnonymoushttp://www.blogger.com/profile/01613713587074301135noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-22587889.post-52576303088192238372007-06-12T14:47:00.000+05:302007-06-12T14:47:00.000+05:30Static methods are always a smell as far as unit t...Static methods are always a smell as far as unit testing is concerned. It is very difficult to unit test code which has calls to static methods. And singletons are very easy to test - you can always mock them using DI containers like Spring or Guice transparently. But a detailed discussion needs a separate blog post :-). However, the point of the current post is to localize the creation logic - whether u implement the factory as a singleton or static methods is the next step.Anonymoushttps://www.blogger.com/profile/01613713587074301135noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-64048434862092456722007-06-11T13:35:00.000+05:302007-06-11T13:35:00.000+05:30Dear Debasish Da,Please highlight the benefits of ...Dear Debasish Da,<BR/>Please highlight the benefits of Singleton instead of static factory methods in BorderObjectFactory class. Is is only for removing hidden dependency? <BR/>One more thing, Java 7 may have some syntax for object creation like Ruby:<BR/><BR/>BorderObject bo = BorderObject.new();<BR/>BorderObject bo = BorderObject.new(1, 2);<BR/>etc.<BR/>Is is related to this scenario.gRoy()https://www.blogger.com/profile/03208451355293337088noreply@blogger.com