This content has been marked as final. Show 2 replies
jz wrote:If the particular class's functionality is being used in multiple classes then you might use inheritance as well.
I am having one class that should be shared between multiple modules. Therefore I defined it with singleton pattern. Now I am wandering is this the optimal solution.
Is it better to remove this singleton pattern and share this object via method parameter. I like the singleton pattern more.
Don't use a singleton :) Simply make the methods and fields public static. This is more efficient. You don't need the overhead of the object instance. It is also faster in respect to firewall/context security checks so execution time will be faster as well.
FYI, Inheritance is also slower in JC so for performance critical applet it should be avoided if possible (from memory, the same goes for interfaces)