I'm designing a simple game application in Java for my OOP exam. The critical point seems to be the database. I've modelled a DBConnector class, which is supposed to manage all interactions with db. These are: 1) provide a list of every song available (this game is kind of like OSU) 2) download/upload of a new song 3) provide a ranking of every game played I've thought the Singleton pattern could be the case for DBConnector, since the entire app needs just one instance of this class. But doing so heavily violetes the Single Responsibility Principle (SRP). In fact, this class could be modified for more than one reason, one for each function previously described [ 1), 2), 3) ]. I was wondering whether applying an adapter interface (thus using the Adapter pattern) between the Singleton class and other classes that use it to retrieve data could improve things. The SRP violation would remain, but at least those classes wouldn't be affected by any changes in the DBConnector code.
Aucun commentaire:
Enregistrer un commentaire