TL;DR: Missing return statements cause unexpected behavior. Problems 😔 Silent failures Unreliable results Hard debugging Inconsistent and misleading behavior Broken logic Solutions 😃 Always return values Use clear flow Validate conditions Test ...
TL;DR: When you use mutable objects as keys in hashed collections, changing them breaks contracts. Problems 😔 Lost Values Hard Debugging The Least Surprise Principle Violation Unexpected Behavior Solutions 😃 Use immutable objects as keys. Overr...
When you ignore your inheritance, you will have trouble with your parents TL;DR: Subclasses should honor ALL their parent’s contract. Problems 😔 Wrong abstraction Subclassification for code reuse Misleading hierarchy Unused or overridden methods ...
TL;DR: Avoid combining the Visitor pattern with instanceof checks. Problems 😔 Open/Closed principle violation Tight Coupling Maintainability Code duplication Poor readability Brittle design IFs Solutions 😃 Implement the Visitor pattern correctl...
TL;DR: Creating a new exception without throwing it leads to silent failures. 👃💩 Problems 😔 Silent failures Unhandled errors Misleading logic Hidden defects Hollow Exceptions Solutions 😃 Always ensure you throw exceptions Check exception usag...
Make your class hierarchy clear and flexible TL;DR: Extract a common abstract class to mimic real-world structure. Problems Addressed Duplicate Code Inappropriate Inheritance Shotgun Surgery Big Class Feature Envy High Coupling Concrete classes su...
TL;DR: Avoid using private methods in parent classes with names that child classes can use. Problems The least surprise principle violation Unexpected behavior and defects Hidden dependencies Limited extensibility Code ambiguity Open/Closed pr...
TL;DR: Functions with unclear names hide intent and confuse readers. Use descriptive, action-oriented names. Problems Unclear function purpose Increased cognitive load Misleading context Reduced readability Difficult collaboration Hidden functional...
TL;DR: Eliminate unused functions, constants, and "just-in-case" code. Problems Addressed Dead Code Just-in-case code Reduced maintainability Anchor Boats Cognitive Load Related Code Smells https://maximilianocontieri.com/code-smell-09-dead-c...
TL;DR: Avoid obfuscated functions in your code. This article is based on a real social hacking disguised as a job interview Problems Hidden vulnerabilities Readability Testability Trust issues Bad Naming Solutions Use clear names Avoid obfu...