Complex database filtering logic can be split between server and client to balance performance and correctness. Keep simple, coarse-grained filtering in SQL queries for performance, while implementing precise filtering logic in the domain model where it's easier to test and maintain. This separation of concerns makes the filtering logic more testable through unit tests rather than slow integration tests, strengthens domain model contracts, and can improve cache hit ratios. The domain model should tolerate wider datasets and filter them down, ensuring correctness even if the database query is slightly imprecise.

14m read timeFrom blog.ploeh.dk
Post cover image
Table of contents
Motivation #How it works #When to use it #Encapsulation #Implementation details #Motivating example #Consequences #Test evidence #Conclusion #

Sort: