r/angularjs • u/WebYourMindtuts • Feb 22 '16
John Papa's Angular 2 Best Practices (DRAFT)
https://github.com/johnpapa/angular-styleguide/blob/master/a2/README.md12
Feb 22 '16
Define small functions, no more than 75 LOC (less is better).
Holy crap. 75? I thought 20 lines was a long function.
4
4
1
Feb 22 '16
I'm all about smaller function, but really, 20 lines of JS is not that much in a lot of cases. I don't think I ever write 75 line functions, but I definitely do over 20 for quite a few cases.
You'd run into micro-optimization issues if you put a hard limit of 20 LOC because it's simply not needed to have small functions for every single thing.
1
Feb 22 '16
Can you give me an example? 20 lines of code can do a lot. I pretty much always find it easier to read a function re-factored to several smaller functions.
1
u/Renegade-One Feb 23 '16
Ya I was like huh?!? Most logic comes from assigning a factory function or object to the scope
2
8
u/heero101086 Feb 22 '16
For a second, I thought, Papa John's uses Angular 2 on their Pizza site?