dimanche 12 avril 2020

Can I have a static class that only has a static variable and a static constructor?

Can I have a static class that only has a static variable and a static constructor to initialize the variable?

For example, can I have a Connection class that only has a static variable called connection and a static constructor to initialize this variable? By calling Connection.connection from another class, I am supposed to get the connection variable. There would be no methods (apart from the static constructor) in this Connection class. Is it anti-pattern to do so? If it is, what would be a better design?

Thanks

Aucun commentaire:

Enregistrer un commentaire