I am building an app for Android that will have multiple data sources depending on who is using it. N-tier architecture with a repository pattern seems like the right way to go about this but I am struggling trying to stick to some base rules.
From what I understand I should be able to write the BL without actually knowing anything about the UI or the DAL. My problem is that once I started writing the UI layer I realized that I need the DAL to run on a background thread. This then forces me to modify my BL/DAL to run async w/ callbacks based on a UI layer requirement which screams "NO" to me.
Here are the 4 layers I have right now and their dependencies.
UI - dependencies on BL and Common/Repository = Android Activities/Fragments. UI Layer will tell the BL which concrete repository/DAL type to use
BL - dependencies on Common/Repository interfaces = Separate package with business rules. Uses the concrete repository that was passed from the UI layer to do stuff
Common/Repository - no dependencies = Separate package with models and interfaces that allows all other layers to interact w/o know about each other. Is this even considered a layer? Should the models be concrete classes or interfaces?
DAL - dependencies on Common/Repository package = Separate package with concrete implementations of the repositories. If Common doesn't have concrete models should each layer have their own concrete models in order to create objects to pass between layers?
What am I missing? I'm trying to force myself out of my comfort zone on this :)