One thing I really like to use is selection or validation based on the Specification pattern, as originally proposed by Martin Fowler and Eric Evans.
Specifications are a very powerful way to perform selection, searching and validation on any object without putting the logic on the object itself. We would really like a way to reuse our business logic, throughout our application, in several use cases, without cluttering our domain object. We also want a way to generalize the selection criterium on a list kind of structure, instead of writing a wrapper around a list based structure that holds some logic that is needed for our problem domain. We also need a way to explicitly state what our business logic is and make it easily reachable, as business logic changes all the time, depending on the wishes of the client, the users of the application, on the weather and other stuff beyond our control ;). This is where the Specification pattern is a great way of doing business with our application.
Continue reading ‘Specification pattern for selection on lists’