Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How do you write code to make it easier for others to understand?

Status
Not open for further replies.

ansh11

Member level 4
Member level 4
Joined
Feb 27, 2018
Messages
71
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
659
Everyone writes code in his own style. How do you write code to make it easier for others to understand?

Do you write comments for each line of your code?

If not then when do you think you should write comments

Do you write code in self commenting code style?


Please share your c code writing experience for embedded systems

Warm regards
ansh
 

Personally, I write a comment at the top of every subroutine to explain what it does and what value, if any, it returns. Any lines that are not immediately obvious are also commented.

All my programs start with a comment block to describe its purpose, the processor or platform it runs on, the date and version number and lists any libraries it needs to be included.

Commenting every line is overkill and clutters the code but anyone seeing it for the first time should be able to understand its basic function and what strategy is used to achieve it.

Brian.
 
Depends, either a summary and / or line by line comments. Depends on
who I think will maintain code or is the audience and experience.


Regards, Dana.
 

I do what Betwixt wrote
I use meaningful variable subroutine names
I also list all of the variable names and what they represent, their expected ranges
and other useful stuff that i might forget otherwise.
 
A well-structured code is somehow self-explanatory by itself, oftentimes requiring few additional comments.
 

Try to imagine that you know nothing about what the program does or how it structured
I would go further, a friend of mine said some time ago: "I add comments as much as possible to even protect the code from myself"
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top