iluwatar / iluwatar/java-design-patterns
Query Object pattern
Nobody has claimed this yet.
- #1714 by @Apeiria01 — closed without merging
- Dominant language
- Java
- Stars
- 94.7k
- Forks
- 27.4k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 10
Description
Description:
The Query Object design pattern encapsulates database queries as objects, allowing for the creation and reuse of complex queries in a more readable and maintainable manner. This pattern separates query construction from execution, promoting single responsibility and enhancing code maintainability. It is particularly useful in systems where queries are complex and frequently changing.
Main Elements:
- Query Object: Encapsulates the query logic. It contains methods to build and customize the query.
- Execution Method: A method to execute the query built by the Query Object.
- Criteria Handling: Mechanisms to add, remove, and combine query criteria dynamically.
- Reusability: Queries can be reused across different parts of the application.
References:
- Martin Fowler's Query Object
- Patterns of Enterprise Application Architecture by Martin Fowler (page 303)
- Hojjat's Blog on Query Object Pattern
Acceptance Criteria:
- Implement a basic Query Object that can construct and execute simple queries.
- Ensure the Query Object can handle dynamic criteria additions, removals, and combinations.
- Provide examples and documentation demonstrating the usage and benefits of the Query Object design pattern.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by surveying the repository's existing pattern implementations and conventions; the issue names no files, tests, or entry points. Compare the design with the linked Martin Fowler references, then determine how a basic Query Object, dynamic criteria handling, execution, examples, and documentation should fit the project. Done means all three acceptance criteria are demonstrated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100