+ 4
How to make nice and clear code, that everyone could understand?
ey c:
5 Respuestas
+ 4
The key to success here is using enters to space different parts of the code. In addition, comments are useful for the public to be able to understand your code. Happy Coding!
+ 3
@RGB good advice. This is what I am saying. Believe me, @frufi, the extra time it takes to put in comments and appropriate spacing is well worth it.
+ 2
// Make
<!-- lots -->
# of
/*
comments
*/
Comments clarify the intent of the code.
/**
* This is a block comment to organize
* code into related sections,
* or even alphabetically
* or by author/coder.
* it's also a good spot for meta-data
* [lookup "javadoc" for
* what the @ things mean]
* @author rgb
* @version .01
* @param myExample takes an example
*/
depending on language {
Use appropriate whitespacing
and indents
to make it easy to find the end bracket;
}
public void commentEverything
{
. . .; // this is another way to organize braces
}
Remember: K.I.S.S. = "Keep It Simple Stupid"
Google "Rube Goldberg Machine" for how NOT to code.
'Stupid' means that documentation "explains it like they[whomever reads it] were 5yrs. old.
Edit: I just Noticed the C# tag, oops! The jist of it should still apply. I believe C# comments use // inline comment and /* block */
+ 1
Excessive use of comments will just dirty up your code and may actually make it more difficult to read. While yes, you should use documentation style comments if it is to be a framework or API, it it usually considered to be a much better practice to name your classes, methods, and variables in a meaningful way so that it reads like a book. Name your classes for what they are, your methods for what they actually do, and your variables for what they represent, etc. Of course, when starting out you will most like use lot of comments to help your learning process and that is not only ok, but encouraged. Check out the SOLID principles and Clean Code.
+ 1
Use brackets all the time even when they are not mandatory. {}
Use indents correctly.
Do make comments in you code.
Give you variables and methods descriptive names.