Component
and Service
type beans and most of the other bean types are by default singleton.
In one of my code Pull requests, I declared a method as static in a Component
as the method wasn't modifying any class level variables.
My code reviewer pointed out that since the class is anyways a Singleton and is going to have a single reference, he said it was unnecessary to make the method static
, but rather make it a public
method.
Which way is the correct way of writing code as most of the classes in my application are Singletons?
Aucun commentaire:
Enregistrer un commentaire