DEV Community

Carlos Galarza
Carlos Galarza

Posted on • Edited on

2 1

How to write accessible code?

accesible code image

  1. Group code blocks in a logical way:

    • Keep your variables close to where they are used.
  2. Use short names:

    • Naming a variable “a” or “b” is fine.
    • But … I lose context, right? … DO NOT! If you respect rule 1, there is no problem, you will reduce the redundancy and the cognitive load of your code.
  3. Use names that speak for themselves:

    • Nothing of “mVal”, “tRows”, etc …
  4. Use the new lines intentionally:

    • In the same way that you divide a text into paragraphs, make the new lines in your code communicate something.

If you want to expand this information I recommend this video, it is based on Go but it applies to other languages as well ->
⚡️⚡️⚡️

Do you wanna know more about this topic and other interesting tech topics?

Follow me on Twitter: https://twitter.com/carloslfu

Thanks! and happy learning.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
craigmc08 profile image
Craig McIlwrath

That first rule is so important. Trying to read a part of a long function (a problem in itself) but ALL of the variables are declared at the beginning of the function. Then you have to read a line, scroll up to figure out the variables, then scroll back down and find your place.

Exhausting.

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay