As a result, in my view, source code is just a means of studying programming.
This blog entry is not about coding any specific language or source code. This one, I'll share some tips to have a "clean" code.
- The first one is about the header of your code. Try to add a header for your file. That header will give other people about your information:
Example:
/* author: BinhMinh
* DateModified:
* Content:
* License (optional) :
* Reference:
* Language:
*/
- Second rule: Always remember "TAB" in coding. A code with tab in newline is always prefered.
Ex1: int func1 (int param1, int param2) {
return 0;
}
Ex2: int fun1 (int param1, int param2) {
return 0;
}
I prefer the Ex1 code.
- Third rule: Try making the name of variable easy to understand. Some people will code with variable like: _1, _2, a, b, c... Of course you will have difficulty in understand your own code later, cause you don't even know those variables do what ?! So make sure you have variables like: count, testingId,...
- Fourth: Try commenting as possible as you can. Those comments will be really useful for reusing codes.
- Fifth: Add documents for your function. If you have seen my Python blog entries, you will see that I always add document for all my functions. Or you can see example in the entry [Java] Math Parser. Not all programmers do this one. But it will help you a lot when you do big projects.
- Sixth: For Java, C,.. use blockscope in conditional expressions no matter what.
B
}
else {
C
}
- Seventh: Try to seperate your codes into independent objects. You can use these objects for other projects.
- Last one: If tired of coding, relax about 15 minutes and then back. Maybe in relaxing time, you will have more ideas for your code.
I just try to have a blog entry about ways of coding cause I've seen so many of my friends' code not clean, not reusable or not just understandable.
Have fun in reading everyone !
https://titandijital.com.tr/
Trả lờiXóatrabzon parça eşya taşıma
zonguldak parça eşya taşıma
kayseri parça eşya taşıma
edirne parça eşya taşıma
RG3M0İ