A warning sign of low code quality. The term has been used in a series of articles and training seminars by
MarkJasonDominus. See the following articles at perl.com:
[Article 1] [Article 2] [Article 3]. See also his
[seminar description].
---
In the seminar, I usually say that a red flag is a sign that you can see in your code that indicates that you should stop and check to see if you have an easy opportunity to make the code better. Sometimes you don't, but often you do.
Here's my current list of 'red flags'. Some of these are Perl-specific; others aren't:
- Repeated code
- Arbitrary numeric constants
- Array length variables
- Backslashed double-quote
- The concatenation operator (.)
- The Condition that Ate Michigan
- C-Style for loops / loop counter variables
- Empty if and else blocks
- Excessively decorated comments
- Families of related variable names
- File-scope lexicals
- Global variables
- Leaning toothpick syndrome
- Making two passes
- Many consecutive prints
- Many very long strings
- Single scalar variable in quotes
- Special case tests
- Taking two steps forward and one step back
- Testing a boolean variable against 0 or 1
- Unbalanced if-else blocks
- unless with else
- Variable use immediately follows assignment
My big discovery was that these few problems are easy to recognize and to fix, and if you find and fix just those problems, you can turn an awful lot of really terrible code into
good code with very little thought.
--MarkJasonDominus