Today I read a lot of articles about how Singleton Pattern is bad, such as
-
violating single responsibility principle
-
inability to subclass
-
inability to use abstract or interface classes
-
High coupling across the application
-
make unit test difficult
And then I remember I have a program with a class named User which has field userName and password and something else related to User. In my conceive the program should only have one user instance, which is created when a human logins in my program. Based on this, should I insist design User class as Singleton Pattern, or is there any good design conceive I should use?
Aucun commentaire:
Enregistrer un commentaire