C0d3z Tips: The Importance of Properly Commenting Your Code!

in #steem8 years ago (edited)

Ever make a complex machine, go back to tinker with it only to realize you built a massive multi thousand line MONSTER just out of reach of your normal understanding..? I have!

While most coders aren't simpleton type individuals every so often the stars align and a wonky code wizard like @KLYE wanders fourth from the primordial ooze to reek havoc on the classical take generally taken by application developers and computer programmers.

With absolutely no formal training and a severly tarnished short term memory one could use the analogy "hide my own easter eggs" to describe the seemingly constant lack of the ability to recall that I face. It's not uncommon in my earlier coding ventures to write the majority of a program, put it down and come back to it only to haveforgotten how the hell the application was built or what does what.. It's already a bit obfuscated or occult in the way I lay down code, couple that with an at one point "underdeveloped" commenting habit coming back to projects was.. for lack of a better term.. an absolutely mindfucking nightmare and strain.

Code Comments Replace Need For Memory

Rather than flopping around trying to parse and understand the code written I've realized that commenting what each function, snippet or chunk of code does GREATLY increases the coders ability to pick up where he left of ass well as have his code be referenced by others without it causing them great mental anguish attempting to decrypt the mess of computer wizard words that generally end up making the majority of the applications created by this wizard.

Not only does commenting allow me to quickly determine "what the hell does this bit do?" it also allows young up and coming coders to borrow any previously unknown ways in my work and deploy it as their own. 2 birds with one stone as they say!

Believe it or not out of the ~2300 lines of nodeJS which makes up my @tippy project I'm currently trying to get the first full version completed and launched nearly 10% is comment. Am I ashamed of this? F*ck no! It's likely the only damn way I'd ever be able to make sense of the incredible machine I've got cooking for our STEEM network. Will update the github here in the next little while to show you folks what Alpha v0.0.14 has gotten to so far.

Remember Folks, Clean Code & Comments Makes Even Mongoloids Like Me Capable of Building Incredibly Intricate Applications.


VOTE
KLYE

for Witness!
Sort:  

Documentation is what makes the world go round. It's just as important for businesses so people know what changes have been made, why, and who made them. It saves countless hours of rework and headache so completely understrand.

Well put! Never really thought of it that way but certainly makes a load of sense!

@klye Got a 100% Vote
The @tippy account was at ~undefined% voting power at time of vote!
Vote power is Generated via RNG (Random Number Generator)

🤖 @Tippy - STEEM & SBD Text-to-Tip Service - by @KLYE 🤖
( click reply & type @tippy help for commands )

Man I am excited about your new project!!! You put out some great stuff. I cant wait to see what tippy does....

I wish it was "new" in the sense of the word. It's been a long time coming!

It will be open sourced though.. I don't believe in hiding but rather sharing trade secrets when it comes to tools that should be used by various parties and communities within our network.

Free code and knowledge > All!

@klye Cast a 100% Vote
The @tippy account was at ~96.26 voting power at time of vote!
Vote power is Generated via RNG (Random Number Generator)

🤖 @Tippy - STEEM & SBD Text-to-Tip Service - by @KLYE 🤖
( click reply & type @tippy help for commands )

As a complete amateur coder, I find it very useful to just write everything I want to do as comments first, and then code around it as I figure it out. Helps with the coding and with remembering what the code does when I read it later. Good to know advanced coders have memory issues too.

@klye Cast a 100% Vote
@tippy was at ~92.78% vote power at time of vote!
Vote power is Generated via RNG (Random Number Generator)

🤖 @Tippy - STEEM & SBD Text-to-Tip Service - by @KLYE 🤖
( click reply & type @tippy help for commands )

I wouldn't consider myself advanced... But I'm a persistent son of a bitch!

It’s good to be modest. Your skills far exceed mine. Thanks for the tippy tip!

Not sure if modest is the adjective I'd use to describe myself.. Insane perhaps!

You are most welcome. Cheers!

for the codes to be maintainable, comments on codes are very important. as for me, i practice putting comments on my code that answers hows and whys. also, i always use meaningful variables not just x and y.

I always find the guys that use 1 letter variables nuts! I've got the logic but not the ability to keep track of half the fucking alphabet to manipulate and display the bits n bytes needed!

@klye Cast a 100% Vote via @tippy

@tippy was at ~75.97% vote power at time of vote!
Vote power is Generated via RNG (Random Number Generator)

🤖 @Tippy - STEEM & SBD Text-to-Tip Service - by @KLYE 🤖
( click reply & type @tippy help for commands )

I'm also a big fan of using the first letter of my variables to indicate what type that variable is. That way, if it's a large function, at a glance you can tell whether you need to convert a variable to a different type or not. I also like to name my variables such that I know roughly what their purpose is. If they are temporary, I usually suffix them with temp. ie:
int iTemp, iCount, iSum;
char cTemp, cChoice;
float fProduct, fSalary;
double dProduct, dSteemReceived;

Whatever method you use to define your variables, trying to be consistent can same you a lot of hassles.

@tippy vote

I've got a "somewhat standardized" means of declaring variables.. It certainly helps a ton!

@klye Cast a 100% Vote via @tippy

@tippy was at ~73.27% vote power at time of vote!
Vote power is Generated via RNG (Random Number Generator)

🤖 @Tippy - STEEM & SBD Text-to-Tip Service - by @KLYE 🤖
( click reply & type @tippy help for commands )

@tippy vote

wow..Nice! this is Kool

Just implemented the feature to show voting % and voting power. :P

@klye Cast a 100% Vote via @tippy

@tippy was at ~89.20% vote power at time of vote!
Vote power is Generated via RNG (Random Number Generator)

🤖 @Tippy - STEEM & SBD Text-to-Tip Service - by @KLYE 🤖
( click reply & type @tippy help for commands )
@followbtcnews Cast a 83.52% Vote
The @tippy account was at ~94.35 voting power at time of vote!
Vote power is Generated via RNG (Random Number Generator)

🤖 @Tippy - STEEM & SBD Text-to-Tip Service - by @KLYE 🤖
( click reply & type @tippy help for commands )

hueheuheuehueh

Its funny I just remembered about this guy. Good to see still around even though not quite the same.

I'd say 25% of my code is comments and references to solutions 🤓

If I might offer an opposing point of view... I've become a believer in the axiom "comments are lies waiting to happen". Over the last year, I've started writing code that reads more like prose. What are your thoughts on granularity, composition, and unit tests as a way to document?