Maxi Contierimaximilianocontieri.com·Sep 10, 2023Code Smell 224 - Deodorant CommentsTL;DR: Don't excuse bad code. Write a clean one! Problems Readability Solutions Rewrite the code and delete the comment Context The term comes from Martin Fowler's book "Refactoring: Improving the Design of Existing Code" Sample Code Wrong # Thi...Discuss·1 like·88 readsCode Smellscode smell
Yonatan Karp-RudinProyonatankarp.com·Sep 4, 2023Kotlin Code Smell 36 - Object CouplingTL;DR: Respect object boundaries: avoid coupling to data and prioritize interfaces and behavior. When you view your objects merely as data holders, you risk violating their encapsulation. Problem Information Hiding Violation Encapsulation Violat...DiscussKotlin Code Smellsclean code
Maxi Contierimaximilianocontieri.com·Sep 3, 2023Code Smell 223 - Racial NamingTL;DR: Avoid old terms like whitelists, blacklists, master, etc. Problems Racial Connotations Exclusionary Language Diverse Perspectives Solutions Use alternative terminology Context Language evolves, and technical terms should follow it. You...Discuss·2 likes·158 readsCode SmellsGeneral Programming
Yonatan Karp-RudinProyonatankarp.com·Aug 30, 2023Kotlin Code Smell 35 - Explicit IterationTL;DR: Avoid index-based iteration. Embrace higher-order collection functions. Problem Violation of encapsulation Lack of declarativeness Solution Opt for forEach() or high-order iterators. Concealing implementation details opens up possibilit...DiscussKotlin Code Smellsclean code
Yonatan Karp-RudinProyonatankarp.com·Aug 28, 2023Kotlin Code Smell 34 - Fragile TestsTL;DR: Steer clear of non-deterministic tests.. Problem Lack of determinism Eroding confidence Time squandered Solution Ensure that the test is fully deterministic. Eradicate any potential for unpredictable behavior. Eliminate test coupling. ...DiscussKotlin Code Smellsclean code
Maxi Contierimaximilianocontieri.com·Aug 28, 2023Code Smell 222 - Comma OperatorTL;DR: Use comma operator just for loops Problems Readability Hidden Defects Solutions Avoid operator usage Prefer foreach operator Break the sentences Context In JavaScript, the comma operator allows you to evaluate multiple expressions se...Discuss·71 readsCode Smellscode smell
Yonatan Karp-RudinProyonatankarp.com·Aug 25, 2023Kotlin Code Smell 33 - CachesTL;DR - Caches discusses the problems with caching, such as coupling and maintainability, and proposes solutions like using an object mediator, testing invalidation scenarios, and modeling real-world cache metaphors. It concludes that caches should b...DiscussKotlin Code Smellsclean code
Yonatan Karp-RudinProyonatankarp.com·Aug 23, 2023Kotlin Code Smell 32 - Repeated CodeProblem Code Duplication Maintainability Don't Repeat Yourself Solution Find repeated patterns (not repeated code). Create an abstraction. Parametrize abstraction calls. Use composition and avoid inheritance. Unit test the new abstraction. ...DiscussKotlin Code Smellsclean code
Yonatan Karp-RudinProyonatankarp.com·Aug 21, 2023Kotlin Code Smell 31 - Not PolymorphicProblems Missed Polymorphism Coupling IFs / Type check Polluting. Names are coupled to types. Solutions Rename methods after what they do. Favor polymorphism. Sample Code Wrong class Array { fun arraySort() { ... } } class List { fun lis...DiscussKotlin Code Smellsclean code
Yonatan Karp-RudinProyonatankarp.com·Aug 18, 2023Kotlin Code Smell 30 - Concrete Classes SubclassifiedProblem Bad Models Coupling Liskov Substitution Violation Method overriding Mapper fault Solution Subclasses should be specializations. Refactor Hierarchies. Favor Composition. Leaf classes should be concrete. Not-leaf classes should be abstract. ...DiscussKotlin Code Smellsclean code