This is a theory question not a practical one.
I'm trying to design a program that follows software best practices. But I am having trouble figuring out the best way to do certain things that allow for Test Driven Development and good Encapsulation and Abstraction while also minimizing coupling.
I planed to have two layers of abstraction, a database management layer, and a table management layer.
class TableManager()
{
init() {
manager = DatabaseManger()
}
do_operation(String operation) {
connection = manager.get_db_connection()
connection.execute(operation)
}
}
This seemed like a good idea because the actual connection details are hidden from the table manager. But it also seems bad because the TableManager is highly coupled to the DatabaseManager and for testing, I would need to have a separate database connection to set up the database state, things like drop the database and table so we test operations when the database does not exist and things like that
Can someone weigh in here and challenge my assumptions? I might be overestimating the importance of some factors or underestimating others. Is this a common problem with a design patter?
Aucun commentaire:
Enregistrer un commentaire