Hi,
I agree about changing only non idempotent classes in a 1st approach.
That's obviously service and events, but could be also few helper and worker
classes.
We need to check the later and decide one by one. And if they are not idempotent then they should not be called helper or worker. Or rather we would
need to refactor them to extract non idempotent methods.
My 2cts (I have still to read the articles an understand the Lombok project and
how we could possibly use it)
Thanks
Jacques
Le 22/04/2020 à 18:39, Daniel Watford a écrit :
Hi again - I forgot the links!
[1] - https://projectlombok.org/features/experimental/UtilityClass
[2] - https://www.informit.com/articles/article.aspx?p=1216151&seqNum=4
On Wed, 22 Apr 2020 at 17:38, Daniel Watford <d...@foomoo.co.uk> wrote:
Hi Suraj,
If the class author's intention was to create a utility class then I would
support demonstrating this by using the private constructor.
The Lombok project briefly describes the case they support with the
@UtilityClass [1].
Private constructors for utility classes also appears in Effective Java
[2].
I'm not sure I would extend the definition of Utility Class to cover
things like PartyServices, though. I would prefer utility classes only
contain functional code - i.e. no side effects - which cannot be the case
for services.
Summary - if a class is a genuine utility class, then we should probably
treat it as such by implementing the private constructor and marking the
class final. I'm not sure about whether the same approach should be applied
to non-utility classes that happen to only have static methods.
Thanks,
Dan.
On Wed, 22 Apr 2020 at 16:02, Suraj Khurana <suraj.khur...@hotwax.co>
wrote:
Hello team,
While checking codebase using QAPlug [1], it is suggesting to 'Make sure
that utility classes (classes that contain only static methods) do not
have
a public constructor' as an efficiency enhancement.
According to it, all our services, events, helper, worker classes which
are
mostly in JAVA should be having a private constructor and must be defined
as 'final' so that the JVM doesn't need to create a data object using that
default constructor everytime and supplies which is time taking.
Please let me know your thoughts on this.
[1]: https://qaplug.com/
--
Best Regards,
Suraj Khurana
Senior Technical Consultant
--
Daniel Watford