Skip to content
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

Why the AssertionConcern is implemented as a base class? #3

Closed
rantri opened this issue Apr 29, 2013 · 2 comments
Closed

Why the AssertionConcern is implemented as a base class? #3

rantri opened this issue Apr 29, 2013 · 2 comments

Comments

@rantri
Copy link

rantri commented Apr 29, 2013

AssertionConcern should be a reusable component and not a base class for every object that need to do assertions.
Composition Over Inheritance

It should be something like this:
https://github.com/phatboyg/Magnum/blob/master/src/Magnum/Guard.cs

@VaughnVernon
Copy link
Owner

Sure we can do that, but that's not composition. I don't mind using a set of static methods for this, yet the static methods in a helper class is not composition. In some ways inheritance is cleaner because it says that "I as an entity" or "I as a value object am concerned with asserting parameters to me an my state." It makes the statement that I as the object care about this. Still, I don't mind it myself if there is a good reason to make AssertionConcern a set of static method.

Since "Composition Over Inheritance" is not applicable in your suggestion, what is your good reason?

@Frikki
Copy link

Frikki commented Jul 11, 2014

I think that the static methods in a helper class approach solves a problem of multiple inheritance. For example, entities could be subclasses of a self-validator base class, but that would prevent them from also being subclasses of the AssertionConcern class, unless either would be a subclass of the other. However, you could quickly end up building classes with too much functionality.

What about injecting the AssertionConcern class into the entities?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants