Tagged articles
2 articles
Page 1 of 1
Su San Talks Tech
Su San Talks Tech
Apr 19, 2025 · Backend Development

How to Refactor Smelly if…else Chains in Java: 5 Clean Design‑Pattern Solutions

This article examines the problems of long if…else statements in Java payment services, explains why they violate the Open‑Closed and Single Responsibility principles, and presents five practical refactoring techniques—including annotations, dynamic bean names, template methods, strategy‑factory, and chain‑of‑responsibility patterns—to eliminate the conditional logic.

DesignPatternsOpenClosedPrincipleStrategyPattern
0 likes · 16 min read
How to Refactor Smelly if…else Chains in Java: 5 Clean Design‑Pattern Solutions
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.

CodeExampleDesignPatternOpenClosedPrinciple
0 likes · 5 min read
Replacing If‑Else with Enum‑Based Channel Rules in Java