O'Reilly logo
live online training icon Live Online training

Structural Design Patterns with Spring

Victor Rentea

Design Patterns are a powerful tool. So powerful that if applied carelessly they can get you into horrible overengineered code. Mastering the underlying principles and knowing why, how, the cost and nuances of applying a pattern can have a huge impact on your code on the long run. Design patterns have evolved dramatically since the classic GoF book: some died, a few amazing ones appeared while others became incredibly simple to implement with Spring and Java 8. However, the underlying principles never changed. We’ll dive deep into these principles, guided by an eXtreme Programming attitude towards a simple, clean, maintainable and testable design. Along the way, besides practicing a lot of refactoring, we’ll uncover some of the most important mechanics lying under the hood of the Spring Framework – by far the most widely used framework in the Java community.

What you'll learn-and how you can apply it

  • Design clean maintainable code by applying good software design principles like SRP, DRY, KISS, SOLID
  • Understand what Aspect Oriented Programming (AOP) is and how it can be implemented, using Interface-, Class-Proxies, bytecode enhancement or instrumentation
  • Learn about the Decorator and Proxy Patterns
  • Understand how the Spring Framework performs most of its “magic”, like @Cacheable, @Transactional, @Secured, @Async...
  • Know when and how to write your own Aspects with Spring
  • Learn to decouple interactions with external systems using Dependency Inversion Principle applied to an Adapter Pattern
  • Learn to shield internals using a Facade Pattern, and its flavors
  • Understand an Evolutionary Architecture approach driven by continuous code extraction

This training course is for you because...

  • You’ve been developing with Spring for a while already, but you want to know more about its internals
  • You want a refresh on good software design principles and refactoring techniques
  • You want to see application of patterns today in modern applications built with Spring
  • You need an infusion of energy and enthusiasm


  • Prior contact with the Spring Framework is highly recommended by not mandatory
  • Basic knowledge of the Adapter, Facade, Proxy and Decorator patterns would help

Recommended Preparation

Recommended Follow-up

About your instructor

  • Victor is one of the best known independent technical trainers in Bucharest, well-known for the passion he puts in every minute of his classes. His training experience is impressive: he trained 1.2K+ developers of 30+ companies over 200+ days of in-house sessions. Today, he is regularly called by companies of all sizes to help bring Software Craftsmanship ideology and eXtreme Programming practices to their technical culture. Victor is the founder of the Bucharest Software Craftsmanship Community in which he shares his ideas (for now, in Romanian). After 14 years of professional career, Victor is currently Lead Architect at IBM, where he practices eXtreme Programming, crafting code and coaching others each day. He is Associate Professor at Politehnica University of Bucharest (UPB), and a key community member, after organizing the largest 3 Bucharest JUG meetups in history. Victor has become internationally renowned for his passion for Clean Code and is now frequently invited to speak at many conferences around the world. His personally commitment is helping other developers grow their passion for code. On victorrentea.ro you can find out more about him, watch his best talks, slides, articles, and other goodies.


The timeframes are only estimates and may vary according to how the class is progressing

Part 1: Adapter Pattern and Dependency Inversion

(45 min) - General Principles: SRP, Coupling, KISS, YAGNI, encapsulate what varies - Adapter Pattern definition - Extracting an Adapter from domain logic (Live-Coding) - Dependency Inversion Principle

Q&A (10 min)

Break (5 minutes)

Part 2: AOP: Proxy and Decorator Patterns

(60 min) - The DRY Principle - Intermediating method calls using the Decorator Pattern - Ways to selectively wire beans in Spring - Manually Creating Interface Proxies from scratch - Manually Creating Class Proxies using CGLIB - Working with Spring @Aspect - Aspects: debugging tips, best practices, alternatives

Q&A (10 min)

Break (5 minutes)

Part 3: Facade and an Evolutionary Architecture

(35 min) - Facade general definition - ‘Extract when it grows’ approach - Facade roles in an enterprise application - Two extraction patterns: horizontal- and vertical- breakdown - The Onion Architecture and the “Pragmatic Onion” - An approach to an Evolutionary Architecture

Q&A (10 min)