S
Simon Harvey
Hi everyone,
I am in the process of making a small application and in the process of
designing and implementing it, I have come accross a sort of general design
related question.
I'm using the fairly typical approach of dividing the application into three
layers - UI - Business Logic - Data Access.
At the moment I am trying to figure out the best wya to let the logic layer
interact with the DataAccess layer. At the moment I have all communications
between the two layers going through a single class called
PersistenceManager. I have two questions:
1. Is it wise to have a single point of communication between two layers. It
seems like it might make serve the purpose of keeping the design relatively
simple. But is there any reason why a single communication channel might be
a bad idea?
(The most important question)
2. Given that the PersistenceManager class acts as *the* interface to the
data access layer - is this the sort of class that should have an interface
made for it? Then as I understand it, I would have the clients of the
PersistenceManager classes actually *talk* in terms of the interface? For
example I wouldnt put:
PersistenceManager pm = new PersistenceManager()
I would put this instead:
IPersistenceManager pm = controller.getPersistenceManager();
I hope the question is relatively clear. I'm just wondering if most people
would create an interface for this sort of situation. Would it be good
practice to do so, or a waste of time?
Many thanks all
Simon
I am in the process of making a small application and in the process of
designing and implementing it, I have come accross a sort of general design
related question.
I'm using the fairly typical approach of dividing the application into three
layers - UI - Business Logic - Data Access.
At the moment I am trying to figure out the best wya to let the logic layer
interact with the DataAccess layer. At the moment I have all communications
between the two layers going through a single class called
PersistenceManager. I have two questions:
1. Is it wise to have a single point of communication between two layers. It
seems like it might make serve the purpose of keeping the design relatively
simple. But is there any reason why a single communication channel might be
a bad idea?
(The most important question)
2. Given that the PersistenceManager class acts as *the* interface to the
data access layer - is this the sort of class that should have an interface
made for it? Then as I understand it, I would have the clients of the
PersistenceManager classes actually *talk* in terms of the interface? For
example I wouldnt put:
PersistenceManager pm = new PersistenceManager()
I would put this instead:
IPersistenceManager pm = controller.getPersistenceManager();
I hope the question is relatively clear. I'm just wondering if most people
would create an interface for this sort of situation. Would it be good
practice to do so, or a waste of time?
Many thanks all
Simon