Reputation: 3361
Just recently, our application expanded to support 4 different UIs.
We have business logic that is integrated into our data layer.
We do not have a physical business layer that separates our UI from our data layer. Often times in the UI, the database is being called directly. Obviously, this causes problems.
My question is, should I implement a physical business layer, and over time, migrate the existing logic in the data layer to the new business layer. Or should I keep the business layer in the same dll as the data layer?
What are your thoughts on adding a business layer to an application without one?
Upvotes: 1
Views: 72
Reputation: 4759
You should definitely introduce some separation of concerns by doing things in different layers. Directly referencing the database from the UI is not sound architecture and will lead to tight coupling and difficulties in maintenance and extensibility later on.
The best time to do this separation is at the beginning, when there are no costs of refactoring involved, but if you expect the product to be expanding, doing it now will also bring significant benefits in terms of extensibility and maintenance.
Here is an approach for introducing a service layer that stays on top of the model and exposes the same functionality that gets reused by multiple UIs and gateways. This layer helps you unify your business logic across all your interfaces and all exposed services (if you ever need to expose functionality/data) which is very important - you definitely don't want to create and change things in multiple places when you can do it in a single place and guarantee 100% consistency.
Regarding the part of the question about physically implementing the logic in a different dll, I think it is not that important and necessary - you will have the most important benefits of using separate layers without having to physically separate them. Maybe it will make sense if you plan on scaling up and you think that having multiple instances of the same layer on multiple machines will solve a problem of yours (e.g. using some king of load balancing approach for) but otherwise I don't think it is mandatory to do it this way.
Good luck!
Upvotes: 2