0

I have a project with four layers:

  1. Domain
  2. Application
  3. Infrastructure
  4. Presentation

I have an email service interface in the Application layer. It takes an interface parameter called INotificationTemplate, which has a method that returns a list of paragraphs for the body of the notification sent by the email service.

The classes implementing INotificationTemplate are currently in the Application layer. Each class corresponds to a specific event, such as "Case Creation" or "Calendar Event Update."

My main question is, should classes implementing INotificationTemplate be in the Domain layer instead?

1

2 Answers 2

2

My main question is, should classes implementing INotificationTemplate be in the Domain layer instead?

No.

As those classes deal with how the notifications look to the user, an argument can be made that they might belong ion the Presentation layer, but they are definitely not part of the core domain concepts of your systems.

The things that belong in the Domain layer are the concepts that remain essentially unchanged, even when the way that users interact with the system or the way the system is implemented radically changes.

If you imagine implementing the system with paper forms, filing cabinets and an army of clerks, then everything that is common between that incarnation and the software incarnation you are working on is part of the domain.

Similarly, if you think about a radically different way of interacting with the software, like entirely speech driven and notifications being transmitted though other channels than email, then the Domain layer should not be affected by that change.

    2

    The thing about layers is they aren't real. It's just a logical grouping.

    Your notification code might be in the Domain if you are writing apps which send notifications. But not if you are writing apps that do something else and just have sending emails as a minor function.

    Layers have multiple things in them and you need to be able to move those things around.

    Layers can be per application, you can have two apps with two domain layers that don't share any components.

    If you are hardcoding the layer into your code via a filename, project, library etc then stop. Split the components in those layer out and make the "layer" a folder.

    Now you can move things around as you change your mind about how to organise them logically, without breaking your code.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.