Skip to content

[UI/Core Split] Refactor DisplayErrorMessage and DisplayConfirmationMessage in Utilities #178

@benfleuty

Description

@benfleuty

The DisplayErrorMessage and DisplayConfirmationMessage methods in Utilities.cs directly interact with MessageBox, which is a UI component. These methods represent UI-specific logic and should not reside in a core utility class.

To achieve a clean UI/Core split, the responsibility for displaying messages should be handled by the UI layer. The core logic should not have direct dependencies on UI elements like MessageBox.

Action:

  1. Create an interface in the core layer that defines the methods for displaying error and confirmation messages (e.g., IMessageDisplayService). These methods should accept the necessary message content but not have UI-specific parameters or return types.
  2. Implement this interface in the UI layer (e.g., MessageDisplayService.cs) using MessageBox or another appropriate UI mechanism.
  3. Inject or provide an instance of the UI-specific IMessageDisplayService implementation to the parts of the core logic that need to trigger message displays.
  4. Modify the core logic to call the methods on the injected IMessageDisplayService instead of directly calling DisplayErrorMessage and DisplayConfirmationMessage.
  5. Remove DisplayErrorMessage and DisplayConfirmationMessage from the Utilities class.
  6. Add or update tests to ensure that the core logic correctly calls the message display service interface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions