Member-only story

Decorator Design Pattern. Real live Java example with Spring Boot.

Daniel Zielinski
6 min readFeb 25, 2023

To fully understand design patterns, without practice and real life examples could be hard, especially for someone who starting his journey with programming. You can learn Design Patterns by analysing UML diagrams and reading someone code, but there is an abstraction layer, that people often use when describing the topic for e.g. using Duck object or something that not really exists in their code, so when you are starting you can imagine everything but you are not sure if your thoughts are right. Reading some high level code without context is often short process and takes you only 2min, but thinking of any possible use cases, can take forever. In this example we will revert this process. The description of problem will be longer but the result will be fast.

To describe the Decorator Design Pattern, I will refer to the topic I wrote about earlier. The topic concerned tracing in microservices. So too fully understand the topic please read the story about setup of Zipkin in Spring Boot first.

Our zipkin instance after setup looks like below. Each line have service name(trace-app) and the first span name(show, select, insert).

--

--

Daniel Zielinski
Daniel Zielinski

Responses (1)