-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DecisionProjectionBase on Java version #33
Comments
I have looked into this, and I am not sure I want to actually change the way it is done at the moment except maybe throw a specific exception to explain what the issue is as NPE is a bit too generic. The NPE can only happen if the event wasn't registered which is always an error :
Regarding adding a custom exception I am curious how you would go about it in the scope of the exercise.
|
Looking at the C# version a0973e2#diff-69cf78d87e13cf1a1f83cd5c2aece0f7L46 what is the behaviour of public void Apply(IDomainEvent @event)
{
When((dynamic)@event);
} When passed an event for which there are no implementations ? is it silently ignored as is the case in the introduced DecisionProjectionBase or does it fail ? A quick test using a c# repl using System;
public interface IBar {}
public class Bar : IBar {}
public class Baz : IBar {}
public sealed class FooBar : Bar {}
// Simple helper for demonstration
public static class ConsolePrinter
{
public static void Print(Bar item)
{
Console.WriteLine("Bar");
}
public static void Print(FooBar item)
{
Console.WriteLine("FooBar");
}
}
class MainClass {
public static void Main (string[] args) {
var bar = new Bar();
var baz = new Baz();
var foo = new FooBar();
IBar[] items = { bar, foo, baz };
foreach (dynamic item in items)
{
ConsolePrinter.Print(item);
}
}
} yields
Therefore I argue that the refactoring in the C# branch actually changes the behaviour of the system from throwing an exception to silently ignoring unregistered events without introducing a specific test ;p |
:) |
Add test to check if event is managed by projection.
Currently, an exception of NullPointer type is raised.
The text was updated successfully, but these errors were encountered: