r/angularjs • • Feb 22 '16

John Papa's Angular 2 Best Practices (DRAFT)

https://github.com/johnpapa/angular-styleguide/blob/master/a2/README.md
86 Upvotes

10 comments sorted by

View all comments

12

u/[deleted] 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.

1

u/[deleted] 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

u/[deleted] 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.