Posty

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 ...

23.07.2024 - A comment on comments

Comments is a part of code that is not executed during runtime. It should be short, concise and necessary. Comment shall be deemed necessary whenever there is a gap between the story that may be described by code only and actual story. It should be cherry on top that adds value by giving more insight to the logic than the naming, formating and the structure. The overriding rule regarding comments should be - keep your code understendable to yourself and future maintainers(possibly you). Do not attach comments to poorly named variables, functions and modules. Try to include as much context as possible within naming and structure. There is a common practice to set comments ide colouring to same as bacground but it is possible to overlook some valuable comment in this case. i stole the title from the book(original author Cal Evans) regards gmarcin

15.07.2024 | simplicity

Another subject from the set of 97 things that every programer should know is simplicity. The most important thing designing software is to provide client with the functionality tailored to their real needs. Managers dont care about tools applied to obtain requested outcome as long as it gets the job done quickly and satisfy the requieements. On the other hand developers mostly need challenge and constant growth. As a consequence nowadays applications tend to be over-engineered and stuffed with additional libraries, frameworks with tons of configuration. Today ive also watched a youtube video of primagean. It was a comment on article titled "Radical simplicity". It is a reason why id written previous paragraph. The article was about technical overhead that is tend to be introduced within the aplications recently. The one good thought was that nowadays applications are able to do more stuff. The main thought was to use the bare minimum and be careful about introducing new d...

14.07.2024 | refactor

Recently ive found good book about programming heuristics. It is a set of short articles giving some advice about how to approach problems connected with design and maintenance of software. The title is "97 things every programmer should known". Each chapter is written by experienced developers willing to share their observations with others. The articles are not specific but gives an overview of the problem and highlights things to pay special attention to. One of the chapters says about refactoring. Firstly it is good to take a step back, define a scope of work to be done and analyse its contents as it is. It is easy to juggle the ideas how great solutions we may introduce instead of existing messy, imperfect code. We all know we are good programmers capable of good design and bold ideas. But in this case i recommend stop thinking about what could be and try to emphatise whith the people who were involved in the process of development of code that we intent to refactor. ...

[WP] 23.06.2023 | subjects

Obraz
  fig 1.1 BehaviorSubject abstraction marble diagram       It is high time to write another part of angular basics revision. Last time i mentioned Subject object. It is also worth to describe other ‚special’ cases of Subject. The first is behavior subject. It is part of powerful tool for reactive programming called rxjs . When writing angular version of exchange app or mars-rover-photos app I was using behavior subject in following way. Start with declaring behavioral subject private field within your service. The following example ilustrates this step: private myDataSubject: BehaviorSubject<any> = new BehaviorSubject<any>( null );     it will declare new private field with myDataSubject name and BehaviorSubject type. The value within <> braces is called type parameter and is a part of TypeScript generic types. In this case it would describe the type of values emited by this subject. on the right side of the assignmen...

[WP] 05.06.2023 | angular-intro

Obraz
fig 1.1 angular application structure overview      Recently I have been re-writing one of my side projects using another js framework. Originaly written in react, after several days and long hours of scrolling and prompting it was re-shaped to Angular version . In this blog post I want to summarize the stuff I have learned about javascript frontend framework developed by Google . There are only class components. No function component nor hooks available in angular. Moreover it requires developer to use typescript straightaway without support for vanillla js which make it less available for beginners. Angular has no dedicated syntax such as jsx/tsx which enables to combine template, controller and styles within single file. It divides the responsibilities to separate view-template.html file and component.ts file which contains logic. It is a good moment to mention that re-renders of the ui uses diferent technique under the hood. Angular utilizes incremental DO...

[WP] 30.05.2023 | redux-toolkit

Obraz
fig 1.1 redux-principles; <source: Tomasz Ducin presentation on frontend architecture>        Hi, in this blog post I’d like to introduce you to redux which is complex state management tool for web applications. I will describe it from a react point of view but it may be used with other frontend frameworks as well. Redux is recommended to be implemented using redux-toolkit - a set of utilities which facilitate developer experience during redux logic implementation. One of redux-toolkit authors is Marc Ericsson (that guy with simpson avatar) To begin with we need to install three packages: react-redux, @types/react-redux and @reduxjs/toolkit. The next step is to create store. Store instance is initialized with configureStore({reducer:{<import your 1st reducer and put its name here!>}) utility. It is also a good location to declare types for rootState(may be called App state) which is main representation of the application state and dispatch....