jeudi 23 février 2023

What happens when incorrectly use static class, singleton class? [closed]

I know there are many advantages of a singleton class over a static class. And I know utility class should be static because it doesn't have any variables and it does not maintain state. My question:

1/ Can I replace static utility class with Singleton? Does it cause performance or memory leaks?

2/ Can I use singleton or static vavariables to store single current informations sush as user information, session information,... and reset it when login again instead of storing it in database (sqlite, shared preference, ...)? Why not?

Aucun commentaire:

Enregistrer un commentaire