Java & Design Patterns

The Java & Design Patterns series explains design principles and patterns through runnable Java code: SOLID, the GoF patterns, dependency injection, Repository and Specification with JPA, DDD, Hexagonal Architecture, ...

Java & Design Patterns

Programming
3 October 2024 15 min read

Repository pattern and Unit of Work with JPA

Here is a very familiar snippet in Spring projects: a service class calls entityManager.createQuery("select o from Order o where ...") right in the middle of payment logic, elsewhere the same query is...

Programming
14 March 2024 14 min read

State pattern and an order state machine

An e-commerce order moves through several states: new, paid, shipped, delivered, cancelled. Each action, such as paying, shipping or cancelling, is valid only in certain states, and the behavior diffe...

See more