Raised This Month: $32 Target: $400
 8% 

[TUT] Code Styling & Good Programming Habits


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-18-2010 , 13:19   Re: [TUT] Code Styling & Good Programming Habits
Reply With Quote #11

Quote:
Originally Posted by Seta00 View Post
People still don't understand what I mean. The space I save using K&R indentation is filled with COMMENTS. No matter how good your code is indented, no matter how many lines you put between the logical blocks, if your code isn't commented, it's fucking harder to understand it.
I can't agree. You don't need comments if the code is intelligently written. It has also nothing to do with the style indentation.

A code which is written to be the simplest to read, like if you was reading english, and with each line can be understanding and checked without the need to read the whole code, doesn't need comments.
They are disadvantages like indicating what the user wanted to do but not what does really the code or comments can be wrong or not updated.
In such case, it would be more consistent to write a code which is easy to understand. So like coding intelligently, commenting in the same way would be more appropriate, only when necessary or like commenting at the start of the function to provide what does the function, explaining the params etc..

There are severals things you could do to improve the readability :

- Well named the variables ;
- Replacing expression by variables ;
- Replacing numeric values by constants or enums ;
- Replacing expression groups by functions ;
- Replacing arrays by structures ;
- Well named the function ;
- Avoiding repetition ;
- Saving the result in a var ;
- Well organized each part of the code ;
- Well presented the code ;
- Keeping the same style for the whole code ;
- etc, etc.

Using comments, yes, but it should be used with parsimony and placed intelligently.
__________________
Arkshine is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode