6. JavaScript is Dynamic
all the obvious pitfalls compounded by
Immature tooling and IDEs
Wildly variable module styles
Best practices vary as language evolves
Server & Client similar yet so different
7. The Talent Pool is ridic
Web Platform
Engineers
jQuery experts
Closures?
9. Progress is staggering
It’s hard to keep up
The next tech might not be usable yet
When it is, you want to actually
be able to use it
10. Refactoring isn’t easy
Callback hell is more than
just deep nesting
!
IDEs can’t help much, yet
!
But flexibility is more important
on the web than anywhere else
19. All code should look the same.
Style
Naming
Punctuation
Indentation
Comments
Case
20. Get everyone together
1. Agree
2. Document
3. Enforce
https://github.com/rwaldron/idiomatic.js/
https://github.com/Seravo/js-winning-style
https://github.com/airbnb/javascript
21. Coding conventions based on
Github analysis
1. >90% use last comma
2. >80% use space indents
3. >55% use single quotes
http://sideeffect.kr/popularconvention/#javascript
22. Lax enforcement begets violations.
Warnings need to fail builds.
These is as important as failed tests.
34. Complexity : ? still 2
function main(a) {
if (a > 5) {
!
} else {
!
}
}
35. Complexity : ? now 3
function main(a) {
if (a > 10) {
!
} else if(a > 5) {
!
}
}
36. Complexity : ? still 3
function main(a) {
if (a > 10) {
!
} else if(a > 5) {
!
} else {
!
}
}
37. Complexity : ? also 3
function main(a) {
if (a > 5) {
if (a > 10) {
!
}
}
}
38. Complexity : 7
function main(a) {
if (a) {
} else if (a) {
}
!
if (other) { }
!
}
for (var i = 0; i < a; i++) {
if (i % 2) {
} else if (i % 3) {
}
}
39. Don’t get hung up on numbers
!
function main() {
/*jshint maxcomplexity:12*/
!
}
//...
!
* note : jshint calculates complexity differently than
complexity-report (plato, grunt-complexity)
54. Code is a liability.
Your job is to provide value with
as little code as possible.
55. How many lines of code does
your main project have right now?
If you don’t know, within 10%,
then you’re ignoring it.
Treat SLOC like credit card debt.
Don’t add to it without knowing the balance.
69. These numbers are for
introspection and exploration
These calculations have been praised and
criticised, promoted and shot down.
(and Halstead died before
being able to defend them)