Last Revision — April 19, 2022
1 Min Read
Complex Conditional
Change Preventers
Conditional Logic
Within a Class
- Null Check (family)
- Temporary Field (caused)
William C. Wake in book (2004): "Refactoring Workbook"
Wake addresses the complex conditional situation as a Special Case code smell with two symptoms - a complex if
statement and/or value checking before doing the actual work [1].
There was a need for a special case to handle. A hotfix that was never adequately fixed could also be the reason for the smell.
The method is doing a specific task, but there is "one special case" to consider.
Special case has to have an extra special test.
def parse_foo(foo: Foo) -> Goo:
if 'zoo' in foo.sample_attribute:
...
...
...
...
...
...
...
Recursive methods always have to have a base case to stop the recursion.