How to write clean code? How to code like a PRO by shadbox

Total Blog Views: 48

Blog Status: publish

Created By: swazahmad Created at: 07-22-2021

Tags: basicprogramming web development logicbuilding clean code procoder

What characteristics the clean code should have?

  • Readable

It should Like You are a Writer/Poet

  • Elegant

It should be a entertaining to read it and make you happy when you going through it.

  • Simple

It should not look like a Nasa Theory

  • Tests

Each scenario should cover from min to max.

  • DRY

The code should follow DRY(Do Not Repeat Yourself) principle , Once portion of code is written of feature so the same function should not be written again, we can write a code in such a way so we can reused it.

  • Documentation

Documentation is the most important part if some other teammate or person open your code so the comment and the instruction should defined for

  1. Which purposed the code is written
  2. Orignal Author of code name should be present
  3. Proper Indentation
  4. If some refference is used need to denfined

How can we achived A perfect clean code?

  • Used Meaning Full names

You will be going to add lots of Classes, Module, Services, Jobs, Variable, Methods, Constant etc.You should always keep in mind , you must need to make a Habitto use meannigful names, Whatever the name you have used It should always fullfill three purposes.

  1. What it does
  2. Why it Exists
  3. How It used

For Example

Variable for storing students number

Wrong Way

int a;

Correct Way

int students_numbers;

  • Single Responsiblity Rule

Classes, Module, Services or Methods are a better way to organize the code in any programming language so when you are writing the code you really need to keep in mind so that communicates its inent.

Wrong Ways

Functions that  do more than 2 task

Correct way

Functions that do only one task

  • Other Major Points need to be keep in mind

  1. Do not add useless comments
  2. Make all folder organized
  3. Make Project Well organized
  4. Always give Proper Naming conventions


swazahmad

Swaz is Practice Lead of ROR Developer. he's a Blogger, Mentor, and Rubyst. He has expertise in Javascript also . he's highly skilled in designing, developing and testing web applications. He enjoys being challenged and interesting with projects that need him to



Comments



  • swazahmad | almost 4 years ago
    Awesome Information Thanks For Sharing
Buy traffic for your website

About Shadbox

we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.

Services

Downloads