Code Smell 04 - String Abusers
Too many parsing, exploding, regex, strcomp, strpos and string manipulation functions.
- Lack of Abstractions
1) Work with objects instead.
2) Replace strings with data structures dealing with object relations.
3) Go back to Perl :)
4) Find Bijection problems between real objects and the strings.
Automated detection is not easy. If code uses too many string functions it can trigger a warning.
- Primitive Obsession
Don't abuse strings. Favor real objects. Find absent protocol to distinguish them from strings.
This article is part of the CodeSmell Series.