CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

Proper Coding

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gtx15



Joined: 19 May 2018
Posts: 25

View user's profile Send private message

Proper Coding
PostPosted: Sat Aug 29, 2020 7:41 am     Reply with quote

Where can I learn Proper coding?
When to capitalize, When to indent, I just heard to use i then k in for loops.
PCM programmer



Joined: 06 Sep 2003
Posts: 21232

View user's profile Send private message

PostPosted: Sat Aug 29, 2020 8:07 am     Reply with quote

Do a web search for this:
Code:
C style guide
temtronic



Joined: 01 Jul 2010
Posts: 7689
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Aug 29, 2020 10:30 am     Reply with quote

Have a look at the 100s of example programs CCS supplies in the 'examples' folder ! It'll help you get used to the CCS 'style' of coding.

The BIG thing for me is to have comments !!! You can never have enough and they don't 'cost' anything.

When using Assembler, it's often to add comments to EVERY line of code, not so when using C. Having lots of comments means you ( or others) will have a better idea what 'this' was for or 'why' a variable is what it is. I've wondered just HOURS after I coded a 'simple' program wonderer WHAT was I thinking.....

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 16429

View user's profile Send private message

PostPosted: Sat Aug 29, 2020 10:35 am     Reply with quote

Yes. Good comments, are critical. Also, remember that variable names
can be 'self informative'. Calling a integer used for a counter 'n', or 'c'
tells you nothing, but calling it int_ctr, tells you what it is when you look
at the code.
temtronic



Joined: 01 Jul 2010
Posts: 7689
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Aug 29, 2020 4:24 pm     Reply with quote

'self_informative' is real handy ! When I started programming, we were only allowed a maximum of 2 characters for a variable name. Things have changed since the 70s...... Very Happy
Ttelmah



Joined: 11 Mar 2010
Posts: 16429

View user's profile Send private message

PostPosted: Sun Aug 30, 2020 2:42 am     Reply with quote

Then as a further comment, 'ALL_CAPITALS', is generally used in C, to
indicate that an item is a macro.
Key is that macro 'pseudo functions', look exactly like genuine functions,
and macro value declarations in code, look just like variables. Using the
'macros use all upper case' indicator, tells you when you see these, what
they are.
Other than this, the use of capitals is generally 'unrestrained'. However
remember that by default CCS does not implement case significance, so
a variable called 'john', and one called 'John' are the same....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group