Too many parsing, exploding, regex, strcomp, strpos and string manipulation functions.
Problems
- Complexity
- Readability
- Maintainability
- Lack of Abstractions
Solutions
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.
Examples
-Serializers
-Parsers
Sample Code
Wrong
Right
Detection
Automated detection is not easy. A warning can be issued if too many string functions are used.
Relations
- Primitive Obsession
More info
Tags
- Mapping
Credits
Photo by Nathaniel Shuman on Unsplash
This article is part of the CodeSmell Series.
Discussion (0)