iluwatar / iluwatar/java-design-patterns

Query Object pattern

Open
#1,308 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #1714 by @Apeiria01 — closed without merging
epic: pattern info: help wanted type: feature
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:
  1. Query Object: Encapsulates the query logic. It contains methods to build and customize the query.
  2. Execution Method: A method to execute the query built by the Query Object.
  3. Criteria Handling: Mechanisms to add, remove, and combine query criteria dynamically.
  4. Reusability: Queries can be reused across different parts of the application.
References:
Acceptance Criteria:
  1. Implement a basic Query Object that can construct and execute simple queries.
  2. Ensure the Query Object can handle dynamic criteria additions, removals, and combinations.
  3. Provide examples and documentation demonstrating the usage and benefits of the Query Object design pattern.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.