.net - SOLID & EventAggregator -


I'm trying to follow as much concrete as I can and I'm working while working in a prism application I am facing the problem:

I have a class that manages all events from the module received from other modules. As there are two responsibilities in the class (for handling the handlers and handling the events) I decided to split the two sections, so that I have to make event handlers public (which seems strange anyway).

What do you prefer in this situation, there can be two responsibilities in a class or who have event handlers public (or what I am missing)?

Regards.

Edit:

To better explain my answer, consider the following example:

  • ModuleX and ModuleY
  • EventA and EventB in a prism application is defined where both modules can reach them.
  • ModuleX contains event handlers for both events.
  • ModuleY Solid (from)

    on single aspects of single responsibility Also consider. : There should be only one responsibility in a class (i.e. only one potential change in the specificity of the software should be able to affect the class specification)

    Interference isolation theory : "Many client-specific interfaces are better than a general-purpose interface." [4]

    Function Requirements For this example, the description of U will be:

    1. Handler Pt for Event A Gist
    2. Register handler for event B
    3. Handle event A
    4. Event B handle

    If your If there is only one class that handles both A and B, then you will break the single responsibility principle. If you register an event handler with the handler defined in the same category, then you will also break the single responsibility principle.

    So what now? By touching everything, you get four squares because these are apparently all different responsibilities. According to Wikipedia, solid theory is easy to enhance and modify existing code; So it should be easy to make your life easier, not difficult.

    If we create four squares, then we are forced to open event handler code outside of the category that it was created. Humble opinion It is possible to maintain the code that handles the event, as well as possibly registering in the smallest scope:

      class MyHandler {public MyHandler} (event aggregator exoggerator) {eventAggregator. GetEvent & lt; EventA & gt; () Register (HandleEventA) } Private Zero HandelEvent A (Eventarges Algos) {}}  

    is now responsible for dealing with Event Code. Although registering this handler; Anyone can think of it as being part of the event handler.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -