Context

I was told that the internal IT development guidelines states that every project architecture must implement “Layering”, see Wikipedia. Three layers are required “DataLayer”, “BusinessLayer” and “UILayer”. Let’s go and take a look.

How they did it

When I opened the solution, I found the three layers. A Domain layer was nowhere to be found. But OK, I can live with an onion-like architecture.

The DataLayer was the first layer I dug into. When I clicked open the project, I only saw two files: Database.vb (yes, it is a VB.NET application, poor me) and DataLayer.vb. I thought someone was pulling my leg. So I clicked open the next project: BusinessLayer. Guess what! I found BusinessLayer.vb and some DTO files.

Let the record state that I am not happy with this attempt to “layering”.

How I do it

Trying to be a good developer, I immediately started refactoring. I wasn’t yet entirely familiar with the application or its business logic. This is not a reason to not refactor! Business logic and code separation are two entirely different things. In the DataLayer I could easily separate four types, so I created three more classes and renamed the DataLayer.vb to GeneralDataProvider.vb. I’ve optimized the Database.vb so DB access is very easy and simple. I performed the same separation process in the BusinessLayer.

On top of it all, I’ve added a Domain layer and moved the DTO’s, general logic and custom list implementations. I’ve referenced the Domain layer in all other layers.