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

8

u/heero101086 Feb 22 '16

For a second, I thought, Papa John's uses Angular 2 on their Pizza site?

8

u/cipherous Feb 22 '16

Only the freshest frameworks for their pizzas

2

u/TheNiXXeD Feb 23 '16

But I thought angular was gluten free :(

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.

4

u/akujinhikari Feb 22 '16

Yeah, I was thinking that too. lol

4

u/SarSha Feb 22 '16

4-6 lines according to Uncle Bob :P

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.

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

u/dmackerman Feb 22 '16

Glad he's working on it. :)