Tagged articles

method extraction

5 articles · Page 1 of 1
samdeepthink
samdeepthink
Sep 8, 2026 · Fundamentals

Why If Nesting Beyond 3 Levels Hides Bugs: Flatten with Guard Clauses

The article demonstrates how deep if nesting (over 3 levels) obscures bugs using a payment callback example where error messages are swapped, then refactors with guard clauses to flatten logic; it also addresses loop nesting by extracting methods to reduce cognitive load, emphasizing keeping conditions close to their handling.

bug preventionclean codecode nesting
0 likes · 10 min read
Why If Nesting Beyond 3 Levels Hides Bugs: Flatten with Guard Clauses
samdeepthink
samdeepthink
Sep 7, 2026 · Fundamentals

Boost Readability by Reordering Code Lines — Data-Flow Order Beats Method Extraction

The article shows how interleaving multiple data-flow chains in a method forces readers to context-switch, and demonstrates that simply reordering lines to follow each chain sequentially — without changing logic or extracting methods — dramatically improves readability, while explaining why method extraction can backfire when variables are shared across chains.

Code Readabilityclean codecode organization
0 likes · 8 min read
Boost Readability by Reordering Code Lines — Data-Flow Order Beats Method Extraction
Alibaba Cloud Developer
Alibaba Cloud Developer
Jul 3, 2023 · Fundamentals

Mastering Code Refactoring: Practical Techniques and Real-World Examples

This article explains the definition, goals, and common techniques of code refactoring, illustrated with clear before‑and‑after Java examples such as method extraction, variable extraction, conditional simplification, and abstract‑class extraction, and concludes with a brief Q&A on best practices.

Abstract Classconditional refactoringmethod extraction
0 likes · 17 min read
Mastering Code Refactoring: Practical Techniques and Real-World Examples
Alibaba Cloud Developer
Alibaba Cloud Developer
Sep 3, 2020 · Fundamentals

Mastering In‑Out Parameters in Java: 5 Refactoring Techniques Explained

This article explores why Java lacks native input‑output parameters, examines common pitfalls when extracting methods, and presents five practical refactoring solutions—including parameter objects, single‑value arrays, tuple classes, holder objects, and return‑value strategies—complete with code samples and usage guidelines.

Design PatternsInOut ParametersJava
0 likes · 25 min read
Mastering In‑Out Parameters in Java: 5 Refactoring Techniques Explained