Skip to content

Instantly share code, notes, and snippets.

@juliomerisio
Created July 20, 2020 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliomerisio/7828bc251d449d00476276a5eda199a1 to your computer and use it in GitHub Desktop.
Save juliomerisio/7828bc251d449d00476276a5eda199a1 to your computer and use it in GitHub Desktop.

Improvement on readability revision

  • Version: 1.0
  • Date: 2020-07-20
  • Author: Julio Merisio
  • Status: in discussion

Introduction

In order to add new features and give maintenance on the code, the developers face some barriers.

Overview

  • Default code style
    • Applies to file names, variables names, code format
    • Allows us to have more clarity and semantic on the code
    • Allows us to search for terms and find everything easily
    • Restricts what is not previous agreed, and reinforce a collective way of thinking.
  • Unique source of truth on Types
    • Applies to data transfer objects
    • Allows tracking interfaces and types and identified data structures
    • Provides reliability and cohesive data information.
  • Properties drilling
    • Applies to Class components and Functional Components
    • Allows to collocate the information nearby the usage
    • Restricts unnecessarily re-renders
    • Reduces the amount of lines of code and the bundle size
  • Handle side effects
    • Applies to state management - redux,
    • Provides a direct way to communicate with the API.
    • Restricts unnecessarily navigation between files.
    • Restricts unnecessarily states: i.e a routine to open a modal at the same page

Default code style

Without a code style It's hard to align every developer into a single line of thought, each file will be a reflect of our own guessing and it reduces the common ground.

Unique source of truth on Types

Interfaces are replicated through the platform in an inconsistent way, making it difficult to identify which one is correct, and above all increasing the number of places to change if there is a change in it.

Properties drilling

In the current situation, to change a child component you have to scale the element tree until you find the function you are calling up. Providing a back and forth between files, and becoming a hunt game.

Handle side effects

Redux is being used for everything, including simple cases where only one key is changed, either to open a modal, or to send information to the server.And this way we add complexity to something that could be solved in a single line of code. As well as it's not easy to find the right trigger to call the action we need

Proposal

This proposal aims to improve the code readability and solve complexity by removing unnecessary lines of code, handling the concerns presented and formally define the terms and concepts ubiquitously and unambiguously for use in documentation, specifications, and discussions involving the topic.

Concepts

With this proposal, the code become flexible in favor of the following concepts:

  • Modifications: Allows you to modify independently and safely
  • The entire team at the same page: Aligning the basic mechanisms, such as style patterns, nomenclature, organization of blocks needed to walk in the project
  • Performance: By avoiding unnecessary rendering, we improve the user experience, enabling smooth navigation.
  • Clarity: Each decision has a reason, and we can count on documentation and a defined way of thinking.

Code style changes

  • Tools and practices that provide automatic formatting and inconsistency alerts, such as Eslint and prettier

Data access changes

  • Remove duplicate interfaces
  • Checking the validity of interfaces

Properties drilling changes

  • Isolate parts of the system so that there is no conflict with the sprint work

Prevent over complexity for developers

Based on the use cases observed so far, manipulate data and understand what is coming from the transfers is painful and unpractical. From a maintenance point of view, this can be a facilitator for bugs and confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment