"Komag" wrote:
"adrianc1982" wrote:
you should avoids comments as much as posible.... coments are evil...
But why? They help me think and remember how it all works together. Do they somehow hurt performance in the background?
please buy this book
Clean Code: A Handbook of Agile Software Craftsmanship
Robert C. Martin
It has a lot of great insight and once you read this book your coding WILL CHANGE. He is not right all the time on his advice but most of the time is spot on.
Coments are evil and most respected coding sites or books will tell you about it, Robert Martin has his say on coments and even though i dont remember by heart and i read this book a while ago more or less he explains coments get outdated fast.
How come can coments get outdated? well lets say you have written thousands of lines of code and you need to refactor or rewrite a good portion of it, or lets say you wrote version 1.0 and you are going to do version 2.0 thats bigger and better and flashier. You are going to modify code and you will have to work twice just to keep coments updated on what you did, and you will modify code maybe hundreds of times until you get it right. I dont think you will modify that coment 100 times and by the time you know your code like the back of your hand you will just ignore the coments and coments will say something wrong about the next piece of code because think about it, you dont need the coment for code to work.
Most programmers and that includes me just ignore there own coments and just make code work and coments will be wrong and misleading, its bloat, you should on the other hand write variables as long and descriptive as posible and make it as if you were writting a book that you or another coder can come back later and read easily without all those coments that dont make sense. Your code is what we will read make it readable dont write variables like x = something or y1 = x+yz because thats why you are probably writting coments. If you write proper code coments become useless and you are probably writing a lot of coments because you are new to coding later on you will understand all code perfectly and wont need that.
Maybe by the time you are done and you want to write another piece of software you will just skip those. But please read the book its a short read and it will give you tons of advice early on now that you are writting code. I wish i had read this book earlier..