Search code examples
architecturebll

Different Types of BLL Classes (Adapter to DA VS BL Only)


I am developing my first multi-layered MVC application. A card game.

I have 3 layers as follows

|Presentation (MVC)| --> |BLL| --> |DAL (repo/unit of work pattern)|

The DAL is mostly generic, my BLL maps almost 1-1 for each table.

Now I have 'special' classes, handling only card game logic (e.g. checking if the hand is valid, checking if anyone has won yet). These classes do not need to communicate with the database. Additional classes: card, player.

Where would it be best for me to place these classes that contain only logic, and do not need to communicate with the DAL? An extra project? Maybe just adjusting my naming conventions?

Any input is much appreciated!


Solution

  • These special classes sound to me as if they would make up the core of your application along with the main objects (card, player, etc.), so they belong into the business logic layer.

    It doesn't matter (and shouldn't) if some of your classes have a connection to other layers and others don't. However, you might want to take a look at Uncle Bob's clean architecture or Alistair Cockburn's hexagonal architecture (aka "Ports and adapters") for inspiration how domain models, use cases and the various layers can (should) be structured. Note that these approaches bring the benefit of additional flexibility to plugin, say, a different persistent mechanism. The price for this is a (some might say slight) increase in complexity.