Spring PetClinic Sample Application: additional examples on Layered, Hexagonal and DDD (Clean/Onion)
Derived from Spring PetClinic Sample Application
-
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
-
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
-
download the repo
-
read and understand the original structure in spring-petclinic-org or the original repo at https://github.com/spring-projects/spring-petclinic
-
compare spring-petclinic-org with the changes in spring-petclinic-layered
-
compare spring-petclinic-layered with the changes in spring-petclinic-layered-hex
-
compare spring-petclinic-layered with the changes in spring-petclinic-layered-ddd, spring-petclinic-layered-clean and spring-petclinic-layered-onion
Project | Separation of Concern | Dependency | Summary |
---|---|---|---|
No |
|
Original before fork |
|
Some |
|
Layered Architecture Example Rewritten from Orginal to usually how people approach traditional Layered Architecture. This is not the only form of traditional Layered Architecture. |
|
Yes |
Driving → Application ← Driven |
Hexagonal Architecture™ Example Rewritten from Layered Architecture Example |
|
Yes |
User Interface → [Application → Domain] ← Infrastructure |
DDD Architecture™ Example Rewritten from Layered Architecture Example |
|
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". |
|
Yes |
User Interface → [Application → Domain] ← Infrastructure |
Onion Architecture™ Example Rewritten from Layered Architecture Example |
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 thePet
object alone is NOT the Domain Model but a domain object inside a Domain Model