iluwatar / iluwatar/java-design-patterns

Identity Field pattern

Open
#1,298 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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 Identity Field design pattern ensures that each object in a system has a unique identifier, which can be used to track the object independently of its database representation. This pattern is particularly useful in systems where objects need to be reconstituted from a persistent storage medium, ensuring that each object retains its unique identity across different sessions and operations.

Main Elements of the Pattern:

  1. Unique Identifier: Each object is assigned a unique identifier, typically a primary key in the database.
  2. Field Mapping: The identifier field in the object corresponds to a unique column in the database table.
  3. Object Persistence: Ensures that the unique identifier is consistently used when saving and retrieving objects from the database.
References
Acceptance Criteria
  1. Unique Identifier Implementation: Each domain object must have a unique identifier field that maps to the primary key in the database.
  2. Persistence Mechanism: Implement a mechanism to ensure that objects are saved and retrieved using their unique identifiers, maintaining consistent identity across sessions.
  3. Unit Tests: Provide comprehensive unit tests to validate the correct assignment, persistence, and retrieval of the unique identifiers for domain objects.

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

No source files, entry points, or existing tests are identified. Start by reviewing the project contribution guidelines and the linked Identity Field references, then determine which domain objects and persistence mechanisms are in scope. Done means unique identifiers are mapped to database primary keys, persistence and retrieval preserve identity, and comprehensive unit tests cover assignment and round trips.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.