Back to articles
Code Smell 319 - Hardcoded Stateless Properties

Code Smell 319 - Hardcoded Stateless Properties

via Dev.toMaxi Contieri

Don't turn collaborators into permanent roommates TL;DR: You should avoid storing stateless utility classes as instance variables initialized with new. Problems 😔 Hardcoded dependencies Testing difficulties High coupling Hidden side effects Rigid design Misleading intent Premature Optimization Stack clutter Solutions 😃 Use dependency injection Pass as parameter Use static methods Inline the logic Use local variables Inline object creation Refactorings ⚙️ Refactoring 024 - Replace Global Variables with Dependency Injection Maxi Contieri Maxi Contieri Maxi Contieri Follow Mar 9 '25 Refactoring 024 - Replace Global Variables with Dependency Injection # webdev # programming # javascript # beginners 1  reaction Comments Add Comment 7 min read Refactoring 030 - Inline Attributes Maxi Contieri Maxi Contieri Maxi Contieri Follow Jul 11 '25 Refactoring 030 - Inline Attributes # webdev # programming # javascript # beginners Comments Add Comment 7 min read Refactoring 007 - Extract Class Maxi Con

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles