Tagged articles
Factory Pattern
76 articles · Page 1 of 1
This tutorial demonstrates implementing the Strategy Pattern in Spring Boot using a calculator example, showing how to register strategy beans via @Component, inject them into a factory map at startup, and route requests dynamically for extensible callback handling without modifying existing code.
Callback HandlingDesign PatternsExtensibility
0 likes · 6 min read

The author reflects on the rarity of encountering a truly skilled programmer and explains how such a colleague’s disciplined habits, thoughtful design choices, and thorough exception handling can dramatically improve code quality and accelerate a developer’s professional growth.
Factory Patterncode qualitycoding habits
0 likes · 5 min read

Learn how to replace sprawling if‑else logic in payment gateways and SaaS platforms by combining the Strategy and Factory patterns, with concrete Spring Boot examples, step‑by‑step code, and a progression from simple to abstract factories that enforce the Open‑Closed principle.
Design PatternsFactory PatternJava
0 likes · 10 min read

The article explains why indiscriminate use of the Java new operator leads to duplicated configuration, hidden complexity, and performance problems, and demonstrates how Factory, Builder, Object‑Pool, and Prototype patterns—illustrated with Spring Boot 3.5.0 code—provide clean, maintainable alternatives that distinguish junior from senior developers.
Builder PatternDesign PatternsFactory Pattern
0 likes · 19 min read

The article shows that interviewers don’t just want you to list design patterns; they assess your ability to identify real scenarios, solve concrete problems, justify trade‑offs, and discuss implementation details, illustrated with payment and order‑processing examples in Java and Spring.
Chain of ResponsibilityDesign PatternsFactory Pattern
0 likes · 11 min read

The article explains how the buildTool factory injects conservative default safety flags (Fail‑Closed), dramatically reduces boilerplate for the 30‑plus methods required by Claude Code's Tool interface, and combines TypeScript compile‑time checks with Zod runtime validation, illustrated with GlobTool, BashTool and FileEditTool examples, while discussing trade‑offs and design recommendations.
Factory PatternSecurityTool Design
0 likes · 16 min read

The article explains that difficulty reading code often stems from unfamiliar design patterns and complex construction logic rather than poor code quality, illustrating with factory and strategy patterns in inventory systems, and provides a checklist to distinguish between genuinely bad code and gaps in a developer’s knowledge.
Design PatternsFactory PatternJava
0 likes · 9 min read

Many developers learn dozens of design patterns but still end up with fragile, hard‑to‑maintain code; the article explains that the real key is to identify system problems first and apply a disciplined engineering decision method, illustrated with concrete Factory, Builder, Strategy, Template, Decorator, Adapter, Observer and Mediator examples.
Builder PatternDesign PatternsFactory Pattern
0 likes · 16 min read

The article shows how replacing module‑level spyOn with a tiny QueryDeps type and a productionDeps factory eliminates implicit coupling, reduces boilerplate, and enables isolated, type‑safe testing of the core query loop in a large Agent project.
AgentFactory PatternMocking
0 likes · 12 min read

Learn how to replace tangled if‑else login code with a clean, extensible architecture using Spring Boot, combining the Factory pattern to instantiate strategy beans and the Strategy pattern to encapsulate each login method (password, WeChat, SMS, etc.), enabling easy addition of new authentication types.
AuthenticationDesign PatternsFactory Pattern
0 likes · 14 min read


java1234Mar 24, 2026 · Backend Development
This article explains how Spring employs five core design patterns—Factory, Singleton, Proxy, Observer, and Template Method—detailing their roles, code examples, and how they contribute to Spring's modular, extensible architecture.
Design PatternsFactory PatternProxy
0 likes · 8 min read

This article walks through ten classic design patterns—Factory, Proxy, Template Method, Strategy, Observer, Chain of Responsibility, Singleton, Builder, Adapter, and Decorator—showing how they are realized in Spring Boot 3.x with concrete e‑commerce, payment, and user‑system examples, and explains their benefits, trade‑offs, and best‑practice usage.
BuilderDesign PatternsFactory Pattern
0 likes · 39 min read

This article walks through designing a flexible login module that supports password, WeChat, and SMS authentication by applying the Strategy and Factory patterns in a Spring Boot project, showing code examples, project structure, and best‑practice tips for clean, maintainable backend development.
Factory PatternJavaSpring Boot
0 likes · 14 min read

This tutorial shows how to combine the Strategy and Factory patterns in a Spring Boot payment system, separating algorithm definition, creation, and execution to achieve a flexible, extensible, and maintainable architecture that adheres to the Open/Closed principle.
Design PatternsFactory PatternJava
0 likes · 7 min read

The article shows how tangled if‑else login code caused by adding password, SMS, WeChat, and Alipay authentication can be refactored using the Strategy and Factory patterns in Spring Boot, resulting in a clean, extensible, plug‑in‑style login module that requires no changes to existing code when new methods are added.
AuthenticationDesign PatternsFactory Pattern
0 likes · 10 min read

This guide walks you through designing a scalable login module that supports dozens of authentication methods by combining the Strategy and Factory patterns with Spring Boot, providing clean code, easy extensibility, and robust testing without the tangled if‑else spaghetti.
Design PatternsFactory PatternJava
0 likes · 12 min read

This article demonstrates how to replace tangled if‑else login code with a clean Spring Boot solution that combines the Factory and Strategy patterns, enabling easy addition of multiple authentication methods such as password, WeChat, SMS, and future providers while improving extensibility, readability, and testability.
AuthenticationBackendFactory Pattern
0 likes · 12 min read

This guide explains PHP 8's match expression, highlighting its strict comparison, return capabilities, and practical examples—including basic rewrites, conditional branches, enum integration, and a driver factory pattern—to help developers replace switch statements with more robust code.
Factory PatternPHPcode refactoring
0 likes · 5 min read

This article walks through building a reusable TypeScript MCP Server framework using strategy and factory patterns, showing project setup, core type definitions, a sample DeployHtml tool, a singleton registry, Express‑SSE integration, automatic tool loading, and a side‑by‑side comparison with a Java implementation.
BackendExpressFactory Pattern
0 likes · 17 min read

This article explains why using the plain new operator is far faster than reflection, shows how an object pool can dramatically reduce memory usage and allocation time, and demonstrates a factory‑plus‑cache pattern that eliminates most repetitive new calls, delivering up to three‑fold performance gains.
BackendFactory PatternJava
0 likes · 6 min read

This article explores how to apply core design patterns—Observer, Factory, Proxy, and Template Method—in Java middleware development, illustrating each pattern with practical code snippets and explaining the design rationale for building maintainable, extensible, and flexible services.
Backend DevelopmentFactory PatternObserver Pattern
0 likes · 8 min read

This article introduces essential design patterns for PHP web service development, such as Factory, Singleton, Observer, Strategy, and Dependency Injection, explains their implementation with code examples, discusses their benefits for code reuse, maintainability, and scalability, and offers guidance on selecting appropriate patterns in modern PHP frameworks.
Design PatternsFactory PatternPHP
0 likes · 8 min read

The article presents a real‑world case of a multi‑tenant system whose business logic was tightly coupled across tenants, leading to a massive service class, and demonstrates how applying Domain‑Driven Design, the Dependency Inversion Principle, and the Factory pattern can restructure the code into isolated tenant‑specific actions, improving maintainability and testability.
Backend ArchitectureFactory Patterncode refactoring
0 likes · 6 min read

This article presents a case study of optimizing a multi‑tenant Java Spring MVC backend by applying domain‑driven design principles, the dependency inversion principle, and a factory pattern to decouple tenant‑specific logic, reduce service size, and improve maintainability and testability.
Backend DevelopmentDDDFactory Pattern
0 likes · 5 min read

This article demonstrates how to replace bulky if‑else discount handling in a SpringBoot shopping service with a clean combination of strategy and factory patterns, providing extensible, maintainable code for various user types and product discounts.
BackendDesign PatternsFactory Pattern
0 likes · 13 min read

This article walks through the JustAuth Spring Boot Starter’s architecture, detailing how the auto‑configuration class, property‑driven bean creation, and factory pattern enable third‑party login integration, while also offering practical tips for reading its source code and understanding key components.
Auto-ConfigurationFactory PatternJava
0 likes · 8 min read

The article presents a Java‑based scenario execution framework that leverages design patterns, annotations, enums and a generic factory to replace repetitive if/else branches with abstract scene interfaces and concrete implementations, enabling developers to add new business cases by simply creating a class and enum constant while the infrastructure automatically discovers and wires it, improving extensibility, readability and code quality.
Design PatternsFactory PatternJava
0 likes · 13 min read

This article introduces design patterns, lists the most common patterns such as Strategy, Factory, Singleton, Proxy, Factory Method, Observer, Template Method, and Adapter, and walks through concrete Java code examples, step‑by‑step explanations, and practical scenarios that demonstrate how each pattern solves specific design problems.
AdapterDesign PatternsFactory Pattern
0 likes · 23 min read

This article examines nine design patterns employed within MyBatis—Builder, Factory, Singleton, Proxy, Decorator, Adapter, Composite, Template Method, and Iterator—detailing their roles, source code examples, and how they facilitate configuration parsing, SQL execution, and caching in the framework.
Builder PatternDesign PatternsFactory Pattern
0 likes · 18 min read

This article provides a comprehensive introduction to common Java design patterns—including Strategy, Factory, Singleton, Proxy, Observer, Template Method, and Adapter—explaining their concepts, typical use‑cases, and complete code implementations with Spring Boot integration for practical application development.
Design PatternsFactory PatternJava
0 likes · 20 min read

This article dissects MyBatis's source code, revealing how more than ten classic design patterns—such as Factory, Singleton, Builder, Adapter, Proxy, Composite, Decorator, Template, Strategy, and Iterator—are applied to decouple complex scenarios, improve extensibility, and streamline ORM operations.
AdapterBackend DevelopmentBuilder
0 likes · 11 min read

The article examines the difficulties of applying Domain-Driven Design to a cloud‑disk file‑upload scenario, demonstrates how to simplify the code by extracting business models, introducing factories and repositories, and explains how these patterns clarify the separation between business and technical concerns.
Factory PatternJavadomain-driven design
0 likes · 20 min read

This article describes how to build a lightweight custom object pool in Java using a LinkedBlockingQueue and a factory interface, detailing its design, implementation, code examples, and a test script that demonstrates borrowing, returning, and size control of pooled objects.
Factory PatternLinkedBlockingQueueconcurrency
0 likes · 7 min read

This article walks through a real‑world order‑processing case, demonstrating how successive design‑pattern refinements—starting with the Chain of Responsibility, then adding Factory, Proxy, Template Method, Observer and distributed messaging—enable multi‑tenant, asynchronous, and scalable backend workflows.
Asynchronous ProcessingChain of ResponsibilityDesign Patterns
0 likes · 15 min read

This guide explains JavaScript design patterns—creational, structural, and behavioral—detailing common examples such as Singleton, Factory, Module, Decorator, Observer, Strategy, and more, and shows how applying these proven solutions can make code clearer, more flexible, maintainable, and scalable.
Creational PatternsDesign PatternsFactory Pattern
0 likes · 28 min read

This article demonstrates how to generate website sitemap.xml files in Java by combining four design patterns—Strategy, Factory, Template Method, and Builder—along with the Open/Closed Principle, providing extensible, maintainable code illustrated with enums, configuration classes, and concrete implementations.
Design PatternsFactory PatternJava
0 likes · 16 min read

This article explains why hard‑coded if‑else logic hinders extensibility, introduces the Strategy pattern, shows its structure and Java implementation for data synchronization, then enhances the design with a Factory to decouple object creation, concluding with best‑practice recommendations.
Design PatternsFactory PatternJava
0 likes · 8 min read

This article analyzes the MyBatis source code, illustrating how it applies a variety of design patterns—including Factory, Singleton, Builder, Adapter, Proxy, Composite, Decorator, Template, Strategy, and Iterator—to solve complex architectural challenges and improve modularity, extensibility, and maintainability.
Backend DevelopmentDesign PatternsFactory Pattern
0 likes · 8 min read

This article reviews the various design patterns—creational, structural, and behavioral—employed within MyBatis's source code, illustrating each pattern with diagrams and explaining their roles in simplifying factory creation, singleton configuration, builders, adapters, proxies, decorators, templates, strategies, and iterators.
Backend DevelopmentDesign PatternsFactory Pattern
0 likes · 12 min read

The article examines how MyBatis applies a variety of creational, structural, and behavioral design patterns—such as Factory, Singleton, Builder, Adapter, Proxy, Composite, Decorator, Template, Strategy, and Iterator—to decouple its over‑twenty‑thousand‑line codebase, improve modularity, and handle complex ORM tasks efficiently.
AdapterBackend DevelopmentBuilder
0 likes · 8 min read

This article walks through a step‑by‑step refactoring of repetitive Java code, illustrating how to extract common methods, use reflection, apply generics with lambda expressions, leverage inheritance and the template method pattern, and finally combine factory, template, and strategy patterns into a clean, reusable solution.
Design PatternsFactory PatternJava
0 likes · 13 min read

This article introduces factory and abstract factory patterns in Python, including their concepts, implementations, and practical examples.
Abstract Factory PatternDesign PatternsFactory Pattern
0 likes · 6 min read

This article explains the concept of coupling, demonstrates how traditional object creation leads to high coupling, and shows how using interfaces, the factory pattern, and reflection—culminating in Spring IOC—can dramatically lower coupling, improve reuse, and simplify maintenance in Java backend development.
Backend DevelopmentFactory PatternIoC
0 likes · 8 min read

This article explores the relationship between design patterns and programming languages, explains various programming paradigms, compares design patterns with architectural patterns, outlines key design principles, and provides extensive Java code examples illustrating factory, strategy, template method, builder, proxy, chain of responsibility, and command patterns in practice.
Builder PatternCode ExamplesDesign Patterns
0 likes · 27 min read

This article explains the three main factory design patterns—Simple Factory, Factory Method, and Abstract Factory—detailing their concepts, typical use cases such as document parsing and browser automation, and providing complete Java‑style code examples to illustrate each pattern's implementation and benefits.
Design PatternFactory PatternJava
0 likes · 12 min read

This article explains why dependency injection reduces coupling compared with direct object creation, walks through traditional instantiation, interface programming, factory methods, and reflection, and shows how Spring IoC combines these techniques to manage object lifecycles and improve code maintainability.
Factory PatternIoCJava
0 likes · 8 min read

The article humorously deconstructs an overly complex Java enterprise setup, illustrating how excessive use of interfaces, abstract classes, factories, dependency injection, XML configuration, and heavyweight IDE tooling leads to bloated, hard‑to‑maintain code that ultimately fails in production.
Design PatternsFactory PatternJava
0 likes · 5 min read


ITPUBDec 12, 2022 · Fundamentals
This article explains how introducing factories in Domain‑Driven Design with Go separates object creation logic from domain responsibilities, hides implementation details, enforces invariants, and improves validation, while showing practical code patterns and design‑pattern choices for simple and complex domain objects.
DDDDomain-Driven DesignFactory Pattern
0 likes · 15 min read

The article demonstrates how to replace fragile if‑else shop‑ranking logic in a Java backend with the Strategy pattern, progressing from simple factories and enums to Spring‑auto‑wired and generic factories, highlighting improved extensibility, reduced coupling, Open‑Closed compliance, and the trade‑off of added abstraction complexity.
Backend DevelopmentFactory PatternGenerics
0 likes · 16 min read

The article explains the Factory design pattern family—Simple Factory, Factory Method, and Abstract Factory—showing how each separates object creation from use, presents Java code and UML examples, and compares their advantages such as decoupling and Open/Closed compliance against drawbacks like increased complexity and class proliferation.
Factory PatternJavaobject-oriented
0 likes · 19 min read

This article explains the factory design pattern, covering simple factory, factory method, and abstract factory variants, their typical use cases such as document parsing and automated testing, and provides complete Java code examples illustrating each implementation.
Design PatternFactory PatternJava
0 likes · 12 min read

The article explains the Factory design pattern’s three main variants—Simple Factory for limited product types, Factory Method for extensible hierarchies, and Abstract Factory for creating families of related objects—illustrated with Java code examples for document parsing, automated testing, and cross‑platform membership systems.
Abstract FactoryDesign PatternsFactory Pattern
0 likes · 11 min read

This article explains how to reduce repetitive Java business code by applying the factory and template‑method patterns for shopping‑cart processing, using custom annotations with reflection to generate API requests, and leveraging bean‑mapping utilities to copy properties between DTO/DO objects, while illustrating each technique with concrete code examples.
AnnotationsFactory PatternJava
0 likes · 21 min read

This article explains Python decorators—from basic closure equivalents to factory‑style registry usage—showing how they register modules, modify function behavior, handle parameters, support multiple decorators, and can decorate both functions and classes, all with clear code examples.
Factory Patternadvanced-pythonclosure
0 likes · 8 min read

This article demonstrates step‑by‑step how to improve existing Java code by applying the Strategy, Factory, and Template Method design patterns, reducing duplicated if‑else branches, adhering to the Open‑Closed and Single‑Responsibility principles, and making the logic more extensible and maintainable.
Design PatternsFactory PatternStrategy Pattern
0 likes · 11 min read

This article explains the differences and similarities between the Factory and Strategy design patterns in Java, provides complete code examples, compares their execution results, and discusses how Strategy can resemble micro‑service composition while reducing code redundancy.
Design PatternsFactory PatternOOP
0 likes · 7 min read

This article compares Java's Factory and Strategy design patterns, explaining their concepts, showing UML diagrams, providing complete code examples, and demonstrating how each pattern affects code structure, flexibility, and maintainability, while drawing parallels to micro‑service architecture.
Factory PatternJavaStrategy Pattern
0 likes · 8 min read

This article describes how a mobile development team refactored a card‑creation feature by applying the Open/Closed and Single‑Responsibility principles, introduced a factory pattern with reflection, and ultimately built a fully automated dynamic injection framework using Java Annotation Processing (APT) to eliminate manual code updates.
AndroidAnnotation ProcessingDesign Principles
0 likes · 13 min read

This article introduces six classic design patterns—Strategy, Chain of Responsibility, Template Method, Observer, Factory, and Singleton—explaining their real‑world business scenarios, core principles, and providing clean Java implementations to help developers write more maintainable and extensible code.
Chain of ResponsibilityDesign PatternsFactory Pattern
0 likes · 25 min read

This article explains how to implement a lottery feature in a Java backend, covering database schema design for prizes, probability limits and records, constructing a prize pool, the random selection algorithm, handling prize limits, and using a factory pattern to distribute various prize types.
AlgorithmBackendFactory Pattern
0 likes · 11 min read

This article explains the differences and similarities between the Factory and Strategy design patterns in Java, provides concrete code examples for each, and discusses how the Strategy pattern can offer more flexible behavior composition compared to the traditional Factory approach.
Design PatternsFactory PatternJava
0 likes · 7 min read

The Vivo Internet Server Team demonstrates how applying classic design patterns—factory, template method, strategy, and state—alongside finite‑state machines or workflow engines can dramatically improve the scalability, maintainability, and extensibility of a visual marketing automation engine for rapidly changing business scenarios.
Factory PatternStrategy PatternTemplate Method
0 likes · 19 min read

This article demonstrates how to replace complex if‑elseif logic with the Strategy pattern combined with simple and reflection‑based factories in a Spring Boot application, enabling clean, extensible handling of multiple advertising page types.
Factory PatternJavaSpring Boot
0 likes · 9 min read

This article reviews creational design patterns—Simple Factory, Factory Method, and Abstract Factory—explaining why factories are needed, outlining their roles, comparing each pattern, and providing Java code demos with practical usage scenarios and best‑practice recommendations.
Abstract FactoryCreational Design PatternsFactory Pattern
0 likes · 18 min read

This article revisits the core creational patterns—Simple Factory, Factory Method, and Abstract Factory—explaining their motivations, role divisions, basic concepts, detailed implementations with Java code, and comparative insights to help developers choose the right pattern for scalable object creation.
Abstract FactoryFactory PatternJava
0 likes · 20 min read


JavaEdgeOct 25, 2020 · Backend Development
This article explains why duplicate code harms maintainability, then demonstrates step‑by‑step refactoring techniques—using factory and template method patterns, custom annotations with reflection, and BeanUtils—to consolidate business logic for different cart types and API calls while preserving extensibility.
AnnotationsDesign PatternsFactory Pattern
0 likes · 15 min read

This article explains the core ideas of Java reflection, demonstrates how to obtain Class objects, create instances, access fields and methods, and discusses common use cases such as Spring IoC, factory patterns, and JDBC driver loading, while also covering its advantages, drawbacks, and best‑practice tips.
BackendFactory PatternJDBC
0 likes · 23 min read

This article explains the three common factory design patterns—simple factory, factory method, and abstract factory—illustrates their Java implementations with product and factory classes, demonstrates client usage, and shows how Spring's dependency injection can replace manual factory instantiation, providing a comprehensive guide for developers.
Abstract FactoryDesign PatternsFactory Pattern
0 likes · 7 min read

This article explains six essential software design patterns—Factory, Singleton, Decorator, Strategy, Proxy, and Observer—covering their concepts, structure, advantages, drawbacks, typical use cases, and provides concise Java code examples for each.
DecoratorFactory PatternJava
0 likes · 19 min read

This article explains the factory pattern—a creational design pattern in Java—by describing its three main variants (simple factory, factory method, abstract factory), their advantages, typical scenarios, detailed UML diagrams, and complete Java code examples illustrating each implementation.
CreationalDesign PatternsFactory Pattern
0 likes · 24 min read

This article shows how to replace tangled if/else permission checks in a Java backend by using enums, a factory class, and the strategy pattern, resulting in cleaner, more extensible code that follows the open‑closed principle.
Factory PatternJavaStrategy Pattern
0 likes · 6 min read

This article explains how to replace tangled if‑else statements in business code with the Strategy and Factory design patterns, demonstrates their implementation in Java and Spring, and shows how to register strategy beans to improve readability and maintainability.
Design PatternsFactory PatternJava
0 likes · 11 min read

This article explains how excessive if‑else statements in business code hurt readability and maintainability, and demonstrates how to replace them with the Strategy and Factory design patterns integrated with Spring, using a food‑delivery discount example and complete Java code snippets.
BackendDesign PatternsFactory Pattern
0 likes · 12 min read

This article explains how to replace tangled if‑else logic in business code with the Strategy and Factory design patterns, integrates them into a Spring application, and demonstrates the resulting improvements in readability, maintainability, and extensibility for discount calculations.
Factory PatternJavaSpring
0 likes · 13 min read

This article examines the problems of deeply nested if‑else statements in Java code and demonstrates how to replace them with cleaner alternatives such as the Factory pattern, enums, the Command pattern, and a simple rule engine, improving readability and maintainability.
Design PatternsFactory PatternJava
0 likes · 9 min read

This article explains the appropriate use cases for the Factory pattern, details the responsibilities and characteristics of the application layer in SOA systems, and provides concrete C# code examples for services, DTOs, and data assemblers to illustrate clean separation of concerns and effective data transfer.
Application LayerC#DDD
0 likes · 18 min read
