- Exclusive Author
- Item was Featured
- Author was Featured
- Author had a File in an Envato Bundle
- Has been a member for 4-5 years
- Sold between 100 000 and 250 000 dollars
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- India
I would like to get answer from experienced CC authors and particularly about JavaScript. Here and there I hear the mention “clean code” on blogs or forums but couldn’t grasp exactly what criteria it points.
I am not much familiar with js fundamentals but only managed to make things without bugs (...and not sure), so understand about where I am. 
Common sense says 1.Minimal variables, 2.Re-usage with functions, 3. Keeping it less etc but sometimes complexity of project seems to force sacrificing the “coding aesthetics” (readability).
For example the costly DOM operation optimization and wider browser support (micro finishings) can lead to double / tripple the amount of variables and conditions used and finally the confusion arises “Is that finished in a minimum possible manner?”
I would like to get advice / light on this subject 
- Envato Staff
- Reviewer
- Sold between 10 000 and 50 000 dollars
- Author was Featured
- Item was Featured
- Has been a member for 4-5 years
- Bought between 50 and 99 items
- Contributed a Tutorial to a Tuts+ Site
- Beta Tester
Although the article examples are written in PHP , the structure applies to almost every language.
http://net.tutsplus.com/tutorials/html-css-techniques/top-15-best-practices-for-writing-super-readable-code/- United States
- Has been a member for 4-5 years
- Exclusive Author
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
I could probably take some tips from that article, but one thing I try to do to keep things clean is to make good use of line breaks. For me, this is the #1 way to keep code readable, and I hate viewing code that doesn’t use them.
- Exclusive Author
- Item was Featured
- Author was Featured
- Author had a File in an Envato Bundle
- Has been a member for 4-5 years
- Sold between 100 000 and 250 000 dollars
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- India
Thanks Philo, some of the tips from that article really helped. Just found that I do write code horizontally (lengthy lines) and it needs breakdown vertically for quick readability. Also deep nesting has good alternatives.
Some good stuff at https://github.com/rwldrn/idiomatic.js/
- United States
- Has been a member for 4-5 years
- Exclusive Author
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
jwmcpeak said
Some good stuff at https://github.com/rwldrn/idiomatic.js/
great resource. The one thing that bugs me is the parentheses spacing though. In school we learn to write like this:
(x + 2) * (y + 2)
so it feels awkward when spacing the parentheses
if ( x ) ...
But I support no spacing for parentheses only, as no spacing at all drives me nuts
(x+2)*(y+2) 
I agree. I prefer (x + 2) as opposed to ( x + 2 ). Too much white spaces can be just as bad as not enough.
If you ask me is just a term, there are so many coders out there each one carry his on scratch.
Most imported is code structure since it’s the start key for optimizing your sheets in performance which is major issue with js but its super forgiven semantic platform anyway.
I am a big fun of shorts vars` shorts function short everything (most coders go this way) ,but that’s just horrible way of doing things on the evnato market from buyer point view .
I’ll tell you this if you see the term clean code just imagine your handwriting look like crap but the end resolute is the same vs those girly beautiful handwriting
.
But since you need to work inside the scoop function with js anyway it will never look clean code to me .
better this way for me
(insane) ? nop() : yes();
.
if (insane)
{
nop();
} else {
yes();
} - Sold between 250 000 and 1 000 000 dollars
- Exclusive Author
- Community Moderator
- Author was Featured
- Bought between 10 and 49 items
- Referred between 200 and 499 users
- Has been a member for 4-5 years
- Won a Competition
I personally would also love to read some stuff on how to keep your php + html + js code clean because combining those three technologies can make a lot of mess in our code ;O
- Sold between 100 000 and 250 000 dollars
- Author was Featured
- Item was Featured
- Most Wanted Bounty Winner
- Bought between 10 and 49 items
- Exclusive Author
- Referred between 10 and 49 users
- Has been a member for 2-3 years
Philo01 said
This should help you get startedAlthough the article examples are written in PHP , the structure applies to almost every language. http://net.tutsplus.com/tutorials/html-css-techniques/top-15-best-practices-for-writing-super-readable-code/
Those are for sure great “clean-code” rules. I’ve always followed some of them and try to follow the remaining 
