Questions tagged [code-smell]
Determining what is and is not a "code smell" is subjective, and varies by language, developer and development methodology. Before you ask if some technique is a "code smell," ask yourself what the consequences to your specific project would be, if you used the technique. Simply asking whether something is a "code smell" or not is too subjective.
177 questions
8 votes
5 answers
4k views
Is it still a code smell if a class knows all subtypes but not using instanceof and downcasting?
According to Instanceof code smell, I know using "instanceof" is a code smell, so suppose there is a game with some Tools: Tool.java: public interface Tool{ public void printInfo(); } ...
0 votes
0 answers
221 views
Is "parallel composition hierarchies" a code smell?
For example, suppose I have a mobile app that uses some user data, the DTO: class UserData{ public: Address address; bool isVerified=false; }; class Address{ }; The UserData may be loaded from ...
6 votes
4 answers
1k views
How to avoid init methods when 2 objects need the reference of each other?
According to https://softwareengineering.stackexchange.com/a/334994/432039, I know init is a code smell and should be avoided, and one of the solutions is to use a builder to hold the state first ...
0 votes
3 answers
386 views
How to refactor "init()" into "physically make them two separate classes"?
According to https://softwareengineering.stackexchange.com/a/334994/432039, I know "init()" method is a code smell, and "physically make them two separate classes" is a way to ...
2 votes
3 answers
291 views
What is the code smell called when API are encapsulated many times [closed]
In legacy code bases, some APIs might be encapsulated by different developers with separate classes many times. Example: public void calculate(int baseIncome) { revenueCalculator.calculate(...
1 vote
3 answers
2k views
Are "Distributed Enums" an Anti-pattern in non-OOP like they seem to be considered in OOP?
I have recently read about the so-called "distributed enum anti-pattern." In particular, as it relates to using enums in conditional statements. (The idea is apparently that if you were to ...
0 votes
2 answers
246 views
Is it a code smell to put selection strategy concerns in an enum class?
Right now, I have this enum, called MemberCategory, defined to be: public enum MemberCategory { MEMBERSHIP("Membership"), GOLD_MEMBERSHIP("Gold"), SILVER_MEMBERSHIP(&...
4 votes
4 answers
2k views
Is checking if a new GUID exists before insert a code smell?
Say I use GUIDs as keys. Considering the chance of a duplicate GUID being generated being what they are, is code like this considered a code smell? Guid newID = GenerateGuid(); while (dictionary....