14.04 code-smells

Yet another blog post after almost one year passed. Hello today id like to write a blog post to refresh my writing skills and think more sharply about computer science questions. "code smells" are common practices that make the code dificult to understand, maintain and extend. The root cause of smells appearing in the codbase is not uniform. It can be caused by deadlines, lack of professionalism or negligence. Nevertheless knoledge of condified code smells may lead to better understanding of the codebase. It can make you less likely to introduce one of them yourself. According to the refactoring-guru website there are six groups of code smells: "Bloaters", "OO-abusers", "Change Preventers", "Dispensables", "Couplers". bullet points about each group: bloaters - code, methods and classes of great size, oo-abusers - incomplete or incorrect aplication of oo programing principles change-preventers - one thing to change requires action in several places (shotgun operation), change of one thing trigger cascade of changes. Dispensables - simply garbage to be reduced or completely deleted Couplers - smells that contribute to excessive coupling between classes. bullet points about each subgroup long-method, large-class ---> keep your classes/functions reasonably small try to abstract interfaces or divide larger methods into subroutines primitive-obsessions --> meaningful data should be organized into own objects if they occur repeatedly long parameter list may be mitigated by passing an object as an agreegate argument or returning numerous parrameters groups from functions Data cloups: big groups of related data should be identified, organised into interconected structures tbc... good day to ya mgrzmil

Komentarze

Popularne posty z tego bloga

[WP] 14.03.2023 | environments

14.07.2024 | refactor

[WP] 16.02.2023 | useRef