Tagged articles

Design Pattern

133 articles · Page 2 of 2
Nullbody Notes
Nullbody Notes
Nov 19, 2020 · Fundamentals

Understanding the Singleton Pattern in Go: Eager vs Lazy Implementations

The article explains Go's singleton pattern, detailing eager (init) and lazy implementations using sync.Mutex and sync.Once, provides full code examples, demonstrates that each accessor returns the same instance, and discusses trade‑offs between memory usage and performance.

Design PatternGoconcurrency
0 likes · 5 min read
Understanding the Singleton Pattern in Go: Eager vs Lazy Implementations
php Courses
php Courses
Nov 6, 2020 · Backend Development

Understanding and Implementing the Facade Pattern in ThinkPHP 5.1

This article explains the Facade feature introduced in ThinkPHP 5.1, demonstrates how to use it for static‑style method calls, shows step‑by‑step code examples, discusses the underlying __callStatic and createFacade mechanisms, and provides best‑practice recommendations for managing multiple facades in complex projects.

Design PatternFacadedependency-injection
0 likes · 11 min read
Understanding and Implementing the Facade Pattern in ThinkPHP 5.1
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Oct 14, 2020 · Fundamentals

Singleton Pattern – Ensuring a Unique Instance in Java

This article explains the definition, class diagram, and multiple Java implementations of the Singleton pattern—including eager, lazy, double‑checked locking, static inner class, and enum approaches—while discussing thread safety, volatile usage, and practical considerations.

Design PatternEnumLazy Initialization
0 likes · 9 min read
Singleton Pattern – Ensuring a Unique Instance in Java
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Sep 9, 2020 · Fundamentals

Understanding the Template Method Design Pattern with Java Examples

This article explains the Template Method design pattern, illustrating its structure with Java code examples—including an abstract Drinks class, concrete Tea and Coffee subclasses, hook methods, and real‑world usages in JDK sorting and Spring's application context—while highlighting advantages, drawbacks, and typical scenarios.

Design PatternHook MethodSpring
0 likes · 12 min read
Understanding the Template Method Design Pattern with Java Examples
21CTO
21CTO
Aug 19, 2020 · Backend Development

Eliminate If‑Else Chains with Enum‑Based Strategy in Java

This article demonstrates how to replace cumbersome if‑else statements with a clean enum‑driven design in Java, using an abstract rule class, concrete channel implementations, and an enhanced enumeration that binds each channel to its processing logic, adhering to the open‑closed principle.

Design PatternEnumOpen-Closed Principle
0 likes · 5 min read
Eliminate If‑Else Chains with Enum‑Based Strategy in Java
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Aug 5, 2020 · Fundamentals

Understanding the Singleton Pattern in Java: Concepts, Implementations, and Applications

This article introduces the Singleton design pattern in Java, explains its purpose of ensuring a single class instance, presents multiple implementation approaches—including eager, lazy, double-checked locking, static inner class, and enum—with code examples, and discusses practical usage scenarios and recommendations.

Design PatternObject-Orientedconcurrency
0 likes · 7 min read
Understanding the Singleton Pattern in Java: Concepts, Implementations, and Applications
Architecture Digest
Architecture Digest
Jul 18, 2020 · Backend Development

Understanding How Spring Handles Circular Dependencies and Its Core Principle

This article explains Spring's three‑level cache mechanism for resolving circular dependencies in singleton beans, demonstrates a simplified implementation with Java code, draws an analogy to the classic two‑sum algorithm, and highlights the essential idea behind circular dependency handling.

Circular DependencyDesign PatternSpring
0 likes · 9 min read
Understanding How Spring Handles Circular Dependencies and Its Core Principle
Programmer DD
Programmer DD
Jun 7, 2020 · Fundamentals

Master the Command Pattern: Decouple Actions for Flexible Software Design

Learn how the Command pattern separates request issuance from execution, introducing roles like Command, ConcreteCommand, Receiver, Invoker, and Client, and see real‑world analogies and examples such as Hystrix and Java’s ThreadPoolExecutor that illustrate its widespread use in modern software.

Command PatternDecouplingDesign Pattern
0 likes · 4 min read
Master the Command Pattern: Decouple Actions for Flexible Software Design
Selected Java Interview Questions
Selected Java Interview Questions
May 9, 2020 · Fundamentals

Java Singleton Pattern: Lazy, Eager, Static Inner Class, Enum, and Double-Checked Locking

This article explains the Java Singleton pattern, covering lazy (thread‑unsafe), eager, static inner‑class, enum, and double‑checked locking implementations, discusses their thread‑safety, performance, and serialization issues, and provides complete code examples for interview preparation.

Design PatternEnumLazy Initialization
0 likes · 6 min read
Java Singleton Pattern: Lazy, Eager, Static Inner Class, Enum, and Double-Checked Locking
FunTester
FunTester
Feb 15, 2020 · Backend Development

Understanding Double-Checked Locking Singleton Pattern in Java

This article explains the double‑checked locking design pattern for thread‑safe singletons in Java, demonstrates its performance drawbacks, and presents alternative implementations such as early initialization, init‑on‑demand holder, and enum‑based singletons, highlighting their advantages and limitations.

Design Patternconcurrencydouble-checked locking
0 likes · 6 min read
Understanding Double-Checked Locking Singleton Pattern in Java
Selected Java Interview Questions
Selected Java Interview Questions
Nov 24, 2019 · Fundamentals

Introduction to the Singleton Design Pattern

The Singleton pattern ensures a class has only one instance, providing a global point of access, and is explained with its definition, implementation steps, advantages, disadvantages, thread‑safety concerns, usage guidelines, and typical real‑world scenarios such as configuration management, logging, and resource pooling.

Design PatternObject-Orientedjava
0 likes · 9 min read
Introduction to the Singleton Design Pattern
Selected Java Interview Questions
Selected Java Interview Questions
Oct 20, 2019 · Fundamentals

Java Singleton Pattern Implementations and Variants

This article explains four main categories of Java singleton implementations—eager (hungry), lazy (lazy), holder, and enum—detailing their basic forms, variations, thread‑safety characteristics, performance trade‑offs, and code examples, while also discussing pitfalls such as reflection and serialization.

Design PatternEnumLazy Initialization
0 likes · 10 min read
Java Singleton Pattern Implementations and Variants
Programmer DD
Programmer DD
Sep 3, 2019 · Backend Development

Mastering Java State Machines with Enums: A Practical Guide

This article explains how Java developers can replace cumbersome if‑else status handling with a finite state machine implemented via enums, illustrating concepts, design patterns, and a complete example of an order‑delivery workflow, complete with diagrams and sample code.

Design PatternEnumbackend development
0 likes · 6 min read
Mastering Java State Machines with Enums: A Practical Guide
Java Backend Technology
Java Backend Technology
Jun 27, 2019 · Backend Development

Is Your Java Singleton Really a Singleton? Thread, Reflection & Serialization Pitfalls

This article examines various Java singleton implementations—eager, lazy, double‑checked locking, static inner class, enum, and Kotlin object—analyzing their thread safety, reflection and serialization vulnerabilities, and shows how to harden them using volatile, constructor guards, and readResolve.

Design PatternEnumSerialization
0 likes · 12 min read
Is Your Java Singleton Really a Singleton? Thread, Reflection & Serialization Pitfalls
Java Captain
Java Captain
Oct 2, 2018 · Fundamentals

Understanding the Singleton Design Pattern in Java: Lazy, Eager, Double‑Check, Volatile, Static Inner Class and Enum Implementations

This article explains the Singleton design pattern in Java, covering its definition, the differences between lazy and eager implementations, thread‑safety issues, multiple code versions (simple, synchronized, double‑checked locking, volatile), and alternative approaches using static inner classes and enums, while discussing atomic operations and instruction reordering.

Design PatternEnumLazy Initialization
0 likes · 14 min read
Understanding the Singleton Design Pattern in Java: Lazy, Eager, Double‑Check, Volatile, Static Inner Class and Enum Implementations
Java Backend Technology
Java Backend Technology
Apr 17, 2018 · Backend Development

Mastering the Singleton Pattern in Java: Eager, Lazy, and Thread‑Safe Implementations

This article explains the concept of design patterns and dives deep into the Singleton pattern in Java, covering its purpose, eager and lazy implementations, thread‑safety challenges, double‑checked locking, volatile usage, static inner class, and enum approaches, while illustrating each with clear code examples and diagrams.

Design PatternDouble-Check LockingEnum
0 likes · 11 min read
Mastering the Singleton Pattern in Java: Eager, Lazy, and Thread‑Safe Implementations
Java Captain
Java Captain
Feb 26, 2018 · Fundamentals

Java Dynamic Proxy Mechanism and Design Pattern Overview

This article explains the Proxy design pattern, details Java's dynamic proxy classes and interfaces from JDK 1.6 source, walks through the step‑by‑step creation process, presents a complete demo implementation, and analyzes the underlying Proxy class generation and InvocationHandler mechanisms.

Design PatternDynamic ProxyJDK
0 likes · 13 min read
Java Dynamic Proxy Mechanism and Design Pattern Overview
Programmer DD
Programmer DD
Dec 6, 2017 · Fundamentals

Mastering Java Singleton: From Lazy Initialization to Enum with Thread‑Safety

This article walks through multiple Java Singleton implementations—lazy initialization, double‑checked locking, volatile‑protected, static‑inner‑class, and enum—explaining their thread‑safety characteristics, the pitfalls of instruction reordering, and how reflection and serialization can break or preserve the pattern.

Design PatternEnumThread Safety
0 likes · 10 min read
Mastering Java Singleton: From Lazy Initialization to Enum with Thread‑Safety
Senior Brother's Insights
Senior Brother's Insights
Dec 4, 2017 · Fundamentals

Mastering Thread‑Safe Singleton in Java: Double‑Check, Static Holder, Enum & Reflection Hacks

Explore multiple Java singleton implementations—including a thread‑safe double‑checked locking version, a static inner‑class approach, an enum‑based solution, and a reflection‑based attack—while learning their key technical details, advantages, pitfalls, and how to protect against serialization and reflection vulnerabilities.

Design PatternEnumThread Safety
0 likes · 6 min read
Mastering Thread‑Safe Singleton in Java: Double‑Check, Static Holder, Enum & Reflection Hacks
Java Captain
Java Captain
Nov 13, 2017 · Fundamentals

Understanding the Singleton Design Pattern in Java: Implementations, Thread Safety, and Best Practices

This article explains the Singleton design pattern in Java, covering its definition, lazy and eager implementations, thread‑safety issues such as double‑checked locking and volatile, and alternative approaches like static inner classes and enums, providing code examples and practical insights.

Design PatternThread Safetydouble-checked locking
0 likes · 14 min read
Understanding the Singleton Design Pattern in Java: Implementations, Thread Safety, and Best Practices
MaGe Linux Operations
MaGe Linux Operations
Oct 5, 2017 · Fundamentals

Master Python Decorators: Concepts, Usage, and Design Patterns

This article explains what Python decorators are, their key characteristics, how to pass arguments, stack multiple decorators, use built‑in decorators from the standard library such as @property and @wraps, and relates decorator functions to the classic decorator design pattern, all illustrated with clear code examples.

Code ExampleDesign Patternfunctools
0 likes · 7 min read
Master Python Decorators: Concepts, Usage, and Design Patterns
Java Captain
Java Captain
Aug 22, 2017 · Fundamentals

Understanding Java Static and Dynamic Proxy Patterns

This article explains the concept of the Proxy design pattern, demonstrates how to implement static and dynamic proxies in Java with complete source code, and analyzes the advantages, limitations, and internal workings of Java's runtime-generated proxy classes.

Design PatternDynamic ProxyStatic Proxy
0 likes · 15 min read
Understanding Java Static and Dynamic Proxy Patterns
Tencent TDS Service
Tencent TDS Service
Mar 9, 2017 · Mobile Development

Mastering the Singleton Pattern in Android: Pitfalls, Best Practices, and Real‑World Implementations

This article explores the Singleton design pattern in depth, covering its definition, various Java implementations, thread‑safety concerns, serialization, reflection and cloning pitfalls, Android‑specific considerations, and practical recommendations for using singletons effectively in mobile projects.

Design PatternEnumThread Safety
0 likes · 38 min read
Mastering the Singleton Pattern in Android: Pitfalls, Best Practices, and Real‑World Implementations

Why the Singleton Pattern Matters: Lazy Loading, Thread Safety, and Real‑World Java Examples

This article explains the Singleton design pattern in Java, illustrates why a single instance is essential for configuration classes, compares eager and lazy initialization, shows thread‑safe implementations, and demonstrates extensions that limit the number of instances with practical code samples.

Design PatternThread Safetyjava
0 likes · 12 min read
Why the Singleton Pattern Matters: Lazy Loading, Thread Safety, and Real‑World Java Examples