So I knowthisideaofnotusingcommentsprobablysoundsincrediblyforeignandstrange, especiallybecausewhenyouwerefirstlearningtodevelop, I'm surethatpeopletoldyou.
Writecomments, right, comments, rightcomments.
It's gonnamakeyourcoateasiertounderstand.
You'regonnaknowwhatyourcodeisdoingwhenyoucomebacktoitin a weekor a monthor a year, andit's justgoingtomakeiteasiertoknowwhat's happening.
Andtheyhave a littlebitoftruthbehindtheirstatement.
Andthisiskindofmyproblemwithcommentsis a lotoftimeswhenpeoplearefirststartingoutwithprogramming, theywriteallthesecommentsthathelpthemunderstandthecodethattheydon't understand.
Butthentheygetintothehabitofdoingthat.
Sothen, evenafteryouunderstandwhat a fourloopis, youstillputthatcommentintheresaying, Loopovereveryelementatone, eventhoughyoualreadyknowwhatishappening.
Thatexplainswhatthedifficultcodedoes, but I thinkinmostcaseswhenyouhavecomplex, difficulttoreadcode.
Theproblemisnotwiththecodeitselfbeingdifficult, butthefactthatthecodeisnotwrittenwell, youcouldmayberewritethiscodein a waythatismoreexplanatoryonitsown.
Nooneknowswhattoactuallymeans, but I thinkthatthatcommentisbad.
Thatisjust a badsignofbadcode, becauseinsteadyoushouldusevariablenamesthatmakessensethatmoneyvariableshouldbechangedto a euros, variableormoneyineurosorsomethingthatexplainsthatit's a eurodollaramount, andthenyou'retooshouldbesetto a variable, a variablethatsaysthisistheconversionratebetweeneuros $2 then, lastly, youshouldhaveyournewmoneyvariableafteryoumultiplyby, theconversionratebesetto a variablethathasalsonamedsomethinglikeUSdollaramountor U.
And I think a lotofthisproblemactuallystemsfromschoolsthemselves.
Forexample, when I wenttocollege, partofmygradeonmostofmyassignmentswasactuallybasedonthecommentsthat I wroteinmycode.
Therewasactually a coupleofclasseswheretheysaidthatyouhadtohave a certainamountofcommentlinesforeverysinglelineofcodethatyouhad, soyouhavetohave a lotofcommentsand I mean a tonofcomments, someofmyprojectsthat I hadtodo.
I hadtowrite a commentforalmosteverysinglelineofcodethat I had, whichwasjustabsurd.
Evenbackthen I thoughtitwasridiculousand I wasverynewtoprogramming.
Butadding a commenttoaddtwonumberstogetherjustfeltabsolutelyridiculoustome.
Buttheyreallypreachitin a lotofschoolsandbootcampsandotherplaces.
And I thinkthatgetspushedonpeoplesomuchthattheythink I justneedtousecommentseverywhere.
Commentsaregood.
They'realwaysgoodthere, neverbad.
Butreallycommentshavesuch a darkersidetothembecausetheybecomeaddedeightsoeasilyas I'vementionedalready.
Sothenexttimethatyou'regoingthroughmakingsomecodechangesandyou'rereadytoputin a commenttoexplainsomethingthat's difficulttounderstand, I reallyimploreyoutotrytofigureoutifthere's a betterwaytowritethatcode.
awaywherethecommentisnolongerneeded, whereyourfunctionnamesandvariablenamesjustdothecommentingforyoubecausemostofthetime 95% ofthetimethereisgoingtobe a solutionwithjustvariablenamesandfunctionnamesthatisgoingtosolvetheproblemthatyou'rerunningintoandyouwon't needcomments.
Themainreason I seeforputtingincommentsintoyourcodeiswhenyouhavecodethatnormallyyouwouldn't writethatway.
Otherthanthat, theyjustbecomeoutofdate, difficulttofollow, and I justcumbersomeoverall.
So I hopewhenyouworkonyournextproject, youuseblesscommentsthatyoudidonthelasttimeandmakeyourcodeeasiertoreadandunderstandthroughvariableandfunctionnamingproperties.