I'm having trouble figuring out a clean way to implement my layering.
Here are the layers I have (lower layers support upper layers, either through inheritence or composition):
Business Logic Layer (BLL)
Datastore Layer (DSL)
Database Layer (DBL), Web-Service Buffer (WSB)
When a BLL object makes a get request, getRecords(), it in turn asks the DSL to fulfill it.
The DSL then decides on weather to use the local DBL, or to use the WSB (which communicates with a remote web-service front end to a "master" DB).
Option 1 - Composition (BLL has-a DSL, DSL has-a DBL)
My problem is that since the DSL and DBL objects are composed within the BLL, they know nothing of the containing BLL, and so how are they supposed to make specific DB querys that include the BLL fields ?
Option 2 - Inheritence (BLL : DSL, DSL : DBL)
Even if the lower layers now have access to a BLL through public/protected inheritence, the question still remains as to how DSL and DBL are to know exactly which specific query strings to generate. I suppose that the BLL could keep a set of static strings, but then that creates a two-way dependency, which I assume is a really flawed design with horrific consequences.
Note: Each BLL has a corresponding table that it is serialized to / deserialized from.
Note: I do not want to use reflection, and would like to limit the use of generics (unless there is absolutely no other way. I'm using genreics for my WSB, which is working out fine, though my prime concern is with generating the BLL-specific query strings within the DSL and DBL layers).
Note: There are going to be many diverse BLL objects that will be using the DSL and DBL layers, not just one (otherwise this would be trivial).
public class BL1
{
private DSL _dsLayer;
public getRecords()
{
// ...
_dsLayer.getRecords();
// ...
}
}
public class DSL
{
private DBL _dbLayer;
private WSB _wsBuffer;
public getRecords()
{
if(_dbLayer.getRecords() != null)
{
return records;
}
else
{
return _wsBuffer.getRecords();
}
}
}
public class DBL
{
private string _db = "file.db3";
public getRecords()
{
select ????? - how to know what fields to grab
}
}
Thank you for taking some time in answering this, it is greatly appreciated.