mardi 21 avril 2020

3 Layers architecture - How should i seperate UI from BL?

i'm working on a simple project in the 3 tiers architecture, and Currently i have this intereface on UI:

public interface IDisplay
{
    void PrintMessage(string msg);
    string GetInput();
    void ClearDisplay();
    void WaitForUser();
}

From this, something like ConsoleDisplay will inherit.

Then on my BL, i'm injecting in the c'tor the display type (using the IDisplay), and using its functions to print menus, receive user input, and validate it (All in the BL).

I mean, it works, but it doesn't seem right to me. From what I've read on online, the UI is supposed to access BL functions, but it feels to me like it would cause a duplicate code in UI, that everyone would have to implement their own menu printing, and common string convertions even though it would be similar. Is it okay? I should just let and display implement his own way of menus?

I would be happy if you could advise me / refer me to good sources that explain the different injection methods and their advantages and disadvantages.

Thank you! :)

Aucun commentaire:

Enregistrer un commentaire