Tagged articles

Enum

133 articles · Page 2 of 2
Top Architect
Top Architect
Aug 29, 2020 · Backend Development

Replacing If‑Else with Enum‑Based Channel Rules in Java

This article demonstrates how to refactor channel‑specific processing logic in Java by introducing an abstract rule class, concrete channel rule implementations, and an enum that binds channel identifiers to their rule objects, thereby eliminating cumbersome if‑else statements and adhering to the open/closed principle.

CodeExampleDesignPatternEnum
0 likes · 5 min read
Replacing If‑Else with Enum‑Based Channel Rules in Java
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
Sohu Tech Products
Sohu Tech Products
Aug 5, 2020 · Fundamentals

Exploring Swift Enum Implementation: SIL, Memory Layout, Raw Values, Associated Values, and Protocols

This article delves into the inner workings of Swift enums—covering their compilation to SIL, memory representation, use of MemoryLayout for size and alignment, techniques for retrieving variable addresses, the role of raw values and associated values, and how default protocols like Equatable and Hashable are automatically provided.

Associated ValueEnumRawValue
0 likes · 19 min read
Exploring Swift Enum Implementation: SIL, Memory Layout, Raw Values, Associated Values, and Protocols
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Jul 2, 2020 · Fundamentals

Understanding Java Enums: Seven Practical Usage Patterns and Best Practices

This article introduces Java's enum type introduced in JDK 1.5, explains seven practical usage patterns—including constants, switch statements, adding methods, overriding methods, implementing interfaces, organizing enums in interfaces, and using EnumSet/EnumMap—while providing code examples, best‑practice guidelines, and comparisons with legacy int or String constants.

Design PatternsEnumbackend
0 likes · 14 min read
Understanding Java Enums: Seven Practical Usage Patterns and Best Practices
Top Architect
Top Architect
Jun 9, 2020 · Backend Development

Unified Exception Handling in Spring Boot Using @ControllerAdvice, Assert, and Enum‑Based Error Codes

The article explains how to replace repetitive try‑catch blocks with a unified exception handling mechanism in Spring Boot by leveraging @ControllerAdvice, custom BaseException, enum‑driven error codes, Assert utilities, and standardized response objects to improve code readability and maintainability.

EnumException HandlingSpring
0 likes · 21 min read
Unified Exception Handling in Spring Boot Using @ControllerAdvice, Assert, and Enum‑Based Error Codes
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
Architect's Tech Stack
Architect's Tech Stack
May 3, 2020 · Backend Development

Unified Exception Handling in Spring Boot: Reducing Try‑Catch Boilerplate with @ControllerAdvice, Assert Utilities, and Enum‑Based Error Codes

This article explains how to implement unified exception handling in Spring Boot using @ControllerAdvice and custom Assert utilities, demonstrates reducing repetitive try‑catch blocks with enum‑based error codes, and shows practical testing of various error scenarios including 404, validation, and database failures.

EnumSpringUnified Response
0 likes · 22 min read
Unified Exception Handling in Spring Boot: Reducing Try‑Catch Boilerplate with @ControllerAdvice, Assert Utilities, and Enum‑Based Error Codes
Java Captain
Java Captain
May 1, 2020 · Backend Development

Unified Exception Handling in Spring Boot Using Assert and Enum-based Error Codes

This article demonstrates how to replace repetitive try‑catch blocks in Java Spring applications with a unified exception handling approach that leverages @ControllerAdvice, custom Assert utilities, and enum‑based error codes to produce clean, maintainable, and internationalized error responses across controllers and services.

EnumException HandlingSpring
0 likes · 20 min read
Unified Exception Handling in Spring Boot Using Assert and Enum-based Error Codes
Programmer DD
Programmer DD
Jan 2, 2020 · Backend Development

Why Do Some Developers Hate Using Enums in API Design?

The article examines why enums, while type‑safe and convenient for input parameters, are often criticized in API return values due to their lack of extensibility and the risk of deserialization errors when newer enum constants appear after version upgrades.

API designEnumSerialization
0 likes · 4 min read
Why Do Some Developers Hate Using Enums in API Design?
Java Captain
Java Captain
Jan 1, 2020 · Fundamentals

Why Enums Are Considered Poor Choices for API Return Values

The article explains why using enums as API return values is often criticized, highlighting their lack of extensibility, potential serialization errors when newer enum values appear, and contrasting this with the safety they provide as input parameters, illustrated with Java examples and community opinions.

API designEnumSerialization
0 likes · 4 min read
Why Enums Are Considered Poor Choices for API Return Values
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
Programmer DD
Programmer DD
Aug 4, 2019 · Backend Development

Master MyBatis TypeHandler: Elegant Enum Mapping and Custom Handlers

Learn how to replace fragile numeric status codes with clean enum handling in Java using MyBatis TypeHandler, explore built‑in handlers like EnumOrdinalTypeHandler and EnumTypeHandler, and create custom handlers for seamless database‑Java type conversion, complete with configuration tips and practical examples.

EnumMyBatisORM
0 likes · 9 min read
Master MyBatis TypeHandler: Elegant Enum Mapping and Custom Handlers
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
Mar 9, 2019 · Fundamentals

Understanding Java Enums: Usage, Switch Cases, Singleton Implementation, and Database Integration

This article explores Java enums in depth, covering their basic definition, typical usage patterns such as iteration and switch statements, implementing singletons, integrating with databases via MyBatis type handlers, and addressing common misconceptions about memory consumption, illustrating each concept with clear code examples.

DatabaseEnumMyBatis
0 likes · 7 min read
Understanding Java Enums: Usage, Switch Cases, Singleton Implementation, and Database Integration
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
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
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