+ 4

How to make nice and clear code, that everyone could understand?

ey c:

27th Jul 2017, 8:21 PM
fruityEcology
fruityEcology - avatar
5 ответов
+ 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!
27th Jul 2017, 8:29 PM
Samantha Hammes
Samantha Hammes - avatar
+ 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.
27th Jul 2017, 9:48 PM
Samantha Hammes
Samantha Hammes - avatar
+ 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 */
27th Jul 2017, 9:44 PM
RGB
RGB - avatar
+ 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.
27th Jul 2017, 10:12 PM
ChaoticDawg
ChaoticDawg - avatar
+ 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.
28th Jul 2017, 5:54 PM
sneeze
sneeze - avatar