Skip to content

abchau/spring-petclinic

 
 

Repository files navigation

Spring PetClinic Sample Application: additional examples on Layered, Hexagonal and DDD (Clean/Onion)

Objectives

  • not to muddle with the original repo

  • not intend to provide a silver bullet

  • not to provide "production ready" code

  • not intend to demostrates how to write tests

  • minimal maintenance effort

Major changes compared to original

  • removed gradle

  • removed check style

  • removed all tests

  • removed all Active Record style codes

  • removed all Hibernate Inheritance Mapping

  • chnaged all fetching strategies to LAZY

  • removed all cascade strategies

  • removed uses of WebDataBinder, Validator, and @ModelAttribute annotation at method level

  • reorganised packages

  • applied PRG pattern

  • added some basic error messages

  • added archiecture tests

How to use

  1. download the repo

  2. read and understand the original structure in spring-petclinic-org or the original repo at https://github.com/spring-projects/spring-petclinic

  3. compare spring-petclinic-org with the changes in spring-petclinic-layered

  4. compare spring-petclinic-layered with the changes in spring-petclinic-layered-hex

  5. compare spring-petclinic-layered with the changes in spring-petclinic-layered-ddd, spring-petclinic-layered-clean and spring-petclinic-layered-onion

Project Structures

Project Separation of Concern Dependency Summary

spring-petclinic-org

No

  • Presentation → Model → Dao

  • Presentation → Dao

  • Model ← Dao

Original before fork

spring-petclinic-layered

Some

  • Presentation → Service → Dao

  • Service → Domain

  • Domain → Dao

  • Domain ← Dao

Layered Architecture Example

Rewritten from Orginal to usually how people approach traditional Layered Architecture.

This is not the only form of traditional Layered Architecture.

spring-petclinic-layered-hex

Yes

Driving → Application ← Driven

Hexagonal Architecture™ Example

Rewritten from Layered Architecture Example

spring-petclinic-layered-ddd

Yes

User Interface → [Application → Domain] ← Infrastructure

DDD Architecture™ Example

Rewritten from Layered Architecture Example

spring-petclinic-layered-clean

Yes

User Interface → [Application → Domain] ← Infrastructure

Clean Architecture™ Example

Rewritten from Layered Architecture Example.

Please note that this is an example of "Clean Architecture™", not "clean architecture".

"Clean Architecture™" is the architecture and exmaple deescribed in the book Clean Architecture™.

"clean architecture" is more like using general English to describe an architecture that anyone can come up with and self-proclaimed as "an architecture that is clean".

spring-petclinic-layered-onion

Yes

User Interface → [Application → Domain] ← Infrastructure

Onion Architecture™ Example

Rewritten from Layered Architecture Example

Layering

Type Layers Remarks 1 Remarts 2 Remarts 3

Original

Kind of Vertically sliced

Layered Architecture

Presentation

Service

Model

Data Access

All of these are a form of Layered Architecture

Hexagonal Architecture™ (Ports and Adapters)

Driving

Application

Driven

Hexagonal, DDD, Clean and Onion Architectures are bascically re-discovery of the same idea at different points in time in different context

DDD Architecture™

User Interface

Application Service

Domain

Infrastructure

These 3 are basically identical with different naming preferences

Clean Architecture™

Onion Architecture™

  • In DDD, everything in a domain package, including sub packages, together is a Domain Model. An object like the Pet object alone is NOT the Domain Model but a domain object inside a Domain Model

Releases

No releases published

Packages

No packages published

Languages

  • CSS 63.8%
  • Java 28.1%
  • HTML 5.5%
  • SCSS 2.4%
  • Dockerfile 0.2%