6 min read
|
Saved February 14, 2026
|
Copied!
Do you care about this?
This article discusses how to manage complex filter logic in applications, particularly when dealing with large data sets. It suggests implementing part of the filtering on the client side for better testability and correctness, while still using server-side queries for performance. The author provides practical examples and considerations for when to apply this approach.
If you do, here's more
Mark Seemann explores the complexities of filtering data within software systems, particularly when dealing with large datasets. He highlights the challenge of balancing performance and correctness when implementing filter logic. Often, applications only need a small subset of data from vast databases. For instance, a user might want to view their latest order from a store with millions of entries. Implementing filtering logic can become cumbersome, especially when SQL queries grow complicated. Seemann suggests that developers can maintain some filtering on the server side for performance while offloading complex logic to the client side for better correctness and easier testing.
By moving intricate filtering logic to a client-side library, developers can leverage various programming techniques to ensure the logic works as intended. This approach allows for a clearer separation of concerns. The server-side query may handle basic filtering, while the client-side logic can apply more detailed checks. However, this introduces some duplication of effort, as the client-side logic must not assume any filtering has already occurred on the server. Seemann emphasizes that this pattern becomes useful when the server-side query is too complicated to verify or maintain effectively.
Encapsulation plays a vital role in this design. The Domain Model should manage input data correctly, ensuring that only relevant information is processed. Seemann uses the example of a restaurant reservation system to illustrate his point. The logic for determining table availability can become prone to errors, so he advocates for incorporating input filtering directly into the Domain Model. This strategy not only simplifies the server-side query but also makes the system more resilient against changes in data access code. In summary, Seemann presents a practical approach to filtering in software systems, prioritizing correctness and maintainability through thoughtful architecture.
Questions about this article
No questions yet.