Tagged articles
Decorator Pattern
29 articles · Page 1 of 1
The article demonstrates how the Decorator Pattern solves coupon stacking, order sensitivity, and class explosion problems in e-commerce by composing discount calculators recursively, with Java implementation examples and real-world JDK/Servlet references.
Class ExplosionComposition Over InheritanceCoupon System
0 likes · 13 min read

This article provides a comprehensive explanation of the Java Decorator pattern, covering its definition, purpose, advantages, disadvantages, and a complete implementation example with four key roles and runnable code demonstrating dynamic behavior extension.
Code ExamplesDecorator PatternJava
0 likes · 5 min read


liandkJun 23, 2026 · Fundamentals
The article introduces the Decorator pattern, explains its purpose of dynamically adding functionality without altering existing classes, illustrates the concept with everyday analogies and a complete Java milk‑tea example, and lists typical use cases and common pitfalls.
Code ExampleDecorator PatternJava
0 likes · 5 min read

After years of piling logging, caching, and security directly into Spring Boot services, the author shows how applying the Decorator pattern—implemented via dedicated @Service beans and @Primary/@Qualifier wiring—creates a clean, extensible chain that respects the Open/Closed Principle, while outlining practical steps, trade‑offs, and pitfalls.
Decorator PatternJavaOpen/Closed Principle
0 likes · 10 min read

This article explains the fundamentals of Java I/O streams, showing how to efficiently read, write, copy, delete, move, and inspect both text and binary files using NIO, Buffered streams, and modern APIs, while providing ready‑to‑use code examples.
Binary filesDecorator PatternFile I/O
0 likes · 18 min read

This article presents a complete MongoDB migration solution, detailing the migration rhythm, code refactoring using a decorator pattern, data source replacement with JImKV, MySQL and ES, bulk and incremental data transfer strategies, and deployment safeguards such as monitoring, gray release, and rollback to ensure a seamless cut‑over without service disruption.
Decorator PatternMongoDBdata migration
0 likes · 8 min read

This article explains how to implement dynamic database switching in MyBatis by intercepting and modifying SQL statements to prepend database names to table names, using JSqlParser and MyBatis interceptors.
Database SwitchingDecorator PatternDynamic SQL
0 likes · 6 min read

The article examines how a growing e‑commerce login module becomes tangled with duplicated code and scattered logic, then demonstrates a step‑by‑step refactor using strategy‑factory, template method, chain‑of‑responsibility and decorator patterns to achieve clear responsibilities, extensibility, and easier maintenance.
Chain of ResponsibilityDecorator PatternSpring Boot
0 likes · 18 min read

This article explains the decorator pattern and how Aspect‑Oriented Programming (AOP) can be used in JavaScript to dynamically extend object behavior, provides classic and Vue‑based code examples, discusses advantages and drawbacks, and outlines practical scenarios for applying decorators in front‑end development.
AOPCode ExampleDecorator Pattern
0 likes · 11 min read

This article demonstrates how to identify long‑method and duplicated code smells in a Java curriculum‑display service and refactor the implementation using the Decorator pattern, providing clear component diagrams, full code examples, and a runnable demo that showcases flexible extensions for different course types.
Bad SmellDecorator PatternJava
0 likes · 11 min read

This article explains the Decorator design pattern, shows how to implement it in Go with interfaces and structs, provides concrete code for encryption and formatting decorators, demonstrates composition, and includes a UML diagram to illustrate the pattern’s structure.
Decorator PatternGodesign patterns
0 likes · 4 min read

This article explains the Decorator (Wrapper) pattern, shows how to apply it in a Spring Boot project with concrete surfing‑service examples, demonstrates single‑ and multi‑layer decorators, and provides complete Java code and controller snippets to illustrate dynamic behavior extension without modifying existing classes.
Decorator PatternJavaSpring Boot
0 likes · 7 min read

This article explains the Decorator Pattern—a design pattern that lets developers extend object behavior without modifying existing code—by describing its core components, showing a generic UML diagram, and providing three detailed Java case studies covering task processing, file I/O, and logging systems.
Decorator PatternJavadesign patterns
0 likes · 12 min read

This article explains the Decorator design pattern, presents its UML structure, describes the roles of abstract components, concrete components, and decorators, and demonstrates three practical Java scenarios—task processing, file I/O, and logging—showing how to extend functionality without modifying existing classes.
Decorator PatternJavadesign patterns
0 likes · 12 min read

This article demonstrates how to use the Decorator (Wrapper) pattern in a Spring Boot application to extend existing services with additional responsibilities, showing both single‑layer and multi‑layer decorations through concrete code examples and controller endpoints.
Decorator PatternJavaSpring Boot
0 likes · 8 min read

This tutorial demonstrates how to integrate the Decorator design pattern into a Spring Boot application, showing a basic interface, concrete services, a simple decorator, and a multi‑layer decorator with full code examples and runtime output.
Decorator PatternJavaSpring Boot
0 likes · 7 min read

The article explains Java’s Decorator pattern, detailing its four roles, how to build abstract components and concrete decorators, demonstrates dynamic runtime extension of object behavior through sample code, compares it with inheritance, Proxy and Adapter patterns, and outlines its advantages, drawbacks, and suitable use cases.
Code ExampleDecorator PatternJava
0 likes · 15 min read

The article describes NetEase Cloud Music’s unified real‑time communication framework, which consolidates disparate audio/video features into a single, container‑based architecture using a common IPlayer interface, dynamic method generation, switchable players, and state‑machine management to streamline development, ensure business isolation, and provide seamless, controllable RTC services across all apps.
Decorator PatternFramework DesignKotlin
0 likes · 11 min read

This article explains the Decorator design pattern, contrasting it with inheritance, and shows how to dynamically extend Java classes—especially I/O streams—using composition, complete with code examples, class diagrams, advantages, drawbacks, and practical usage scenarios.
CompositionDecorator PatternInheritance
0 likes · 15 min read

This article introduces microservice concepts, explains GoKit's architecture and onion model, and walks through building a simple calculation service in Go, progressively adding logging, metrics, and middleware using the decorator pattern to achieve a clean, decoupled three‑layer design.
Decorator PatternGoGoKit
0 likes · 14 min read

Through a teacher‑student dialogue, the article demonstrates how the Strategy (with Adapter), State, Observer, Builder, and Decorator patterns can be applied to reward distribution, task management, and activity modeling, illustrating how these patterns decouple logic, enhance extensibility, and improve code maintainability.
Builder PatternDecorator PatternObserver Pattern
0 likes · 24 min read

This article explains how to employ SLF4J's MDC feature to attach a request identifier to log entries, demonstrates why it fails in asynchronous threads, and shows how to fix the issue with a decorator‑style MDCRunnable that propagates the MDC context to child threads and thread pools.
Decorator PatternJavaMDC
0 likes · 10 min read

This article explains how to use SLF4J's MDC feature to attach a request ID to log entries, enabling fast filtering of all logs belonging to a single request even across asynchronous threads and thread pools, and shows a decorator‑based solution for proper propagation.
Decorator PatternJavaLogging
0 likes · 10 min read

This article walks through the proxy and decorator design patterns using a coffee‑ordering example, compares their differences, explains how Spring AOP relies on proxy mechanisms, and demonstrates building a custom dynamic proxy for SMS cost tracking with JDK InvocationHandler and cglib.
AOPCGLIBDecorator Pattern
0 likes · 10 min read

Learn how the Decorator pattern lets you dynamically add responsibilities to objects in Java without subclass explosion, covering its definition, core components, concrete examples with scroll‑bar decorators, advantages over inheritance, drawbacks, suitable scenarios, and best‑practice guidelines for flexible, maintainable code.
Code ExampleDecorator PatternJava
0 likes · 7 min read

This article explains the Decorator design pattern in Java, detailing its four core participants—Component, ConcreteComponent, Decorator, and ConcreteDecorator—through UML diagrams and complete code examples, and also illustrates how Java’s InputStream hierarchy uses FilterInputStream as a real‑world decorator.
Decorator PatternInputStreamJava
0 likes · 5 min read

The article explains the Decorator pattern in Go, defining it as a way to add behavior to objects without altering their structure, illustrates the concept with everyday analogies and provides complete Go code examples—including a basic Showable interface, a plain Girl struct, and makeup decorators that wrap the original object—to demonstrate how layered decorations work transparently at runtime.
Decorator PatternGoObject Composition
0 likes · 4 min read

This article explains the Decorator design pattern, compares a naïve inheritance approach with a proper decorator implementation in Java, provides complete code examples, class diagram, usage scenarios, advantages, and disadvantages, demonstrating how to dynamically extend object behavior without modifying existing code.
Decorator PatternJavadesign patterns
0 likes · 10 min read

This article provides a comprehensive guide to Java I/O, explaining the distinction between byte and character streams, the role of abstract and concrete stream classes, how the Decorator pattern extends functionality, the enhancements introduced in NIO.2, and the use of asynchronous I/O with Futures and Callbacks.
Decorator PatternI/OJava
0 likes · 28 min read
