Hello,
I have a process class, where if the input contains a value it will also do something else.
For example
Person { name; age }
ProcessPerson(person) //takes in a person
in the ProcessPerson
if the age is = over 18 (Adult) then send an email.
The ProcessPerson
already exists, and the base logic has to be run no matter what (save the person to the DB).
At the moment, there is only 1 condition where this extra logic is run, but it looks like there will be points in the future where there will be more added.
I can think of 2 ways of solving this, and wanted a soundboard session:
- Inheritance -> create a derived class called
ProcessAdult
- Events -> post saving the person to the DB, raise a processed event. Add a handler which sends the email.
I prefer the latter of the 2. Or perhaps there is another clean and extensible method that I have not thought of?