angular js and how you shouldn’t use it. once in a blue moon… one day our customer came to us...
TRANSCRIPT
![Page 1: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/1.jpg)
Angular JSAnd how you shouldn’t
use it
![Page 2: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/2.jpg)
Once in a blue moon…
• One day our customer came to us and said that he really wants to hire 3 senior developer for at least a month.
![Page 3: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/3.jpg)
And we hired 3 juniors…
![Page 4: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/4.jpg)
Scope Pollution
![Page 5: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/5.jpg)
Scope Pollution
• Don’t store all your temporary states, variables, parameters or anything else which is not supposed to be (spell-)bound.
![Page 6: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/6.jpg)
Scope Pollution
• You can create a service to share/store some states.• Or use OOP and store your temp variables, state inside your objects
(e.g. Controller object).• Or use messaging.• Or anything else your creativity will invent.
![Page 7: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/7.jpg)
Don’t take Angular JS as a dogma, or religion, or religious dogma
![Page 8: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/8.jpg)
Don’t chain calls if they can be done simultaneously
![Page 9: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/9.jpg)
Just make them run simultaneously!
![Page 10: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/10.jpg)
Don’t violate and misuse ng event model.• One should understand the event (messaging) model before using it.• It’s so easy – where can be any underwater stones? You’re welcome!
![Page 11: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/11.jpg)
Once in a real life… or twice…
![Page 12: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/12.jpg)
...and don’t take my words as a dogma or religion, or religious dogma
![Page 13: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/13.jpg)
Spaghetti code
![Page 14: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/14.jpg)
Nice code, I like it, WAT is wrong with it?• So this slide is not for you =)• Declare a directive-constructing function somewhere else if your
directive is big enough.• Declare a controller-function not inside your directive function, if it’s
big enough.• Declare http-result processing callback as a separate functions.• Extract any other big-enough callbacks in a separate functions.
![Page 15: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/15.jpg)
![Page 16: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/16.jpg)
Spaghetti code
![Page 17: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/17.jpg)
![Page 18: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/18.jpg)
![Page 19: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/19.jpg)
DOM manipulations, $compile in Controllers???Just an ordinary controller – thousandzzz of them!
This sample wasn’t crawling out from darkest corners of my mind
![Page 20: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/20.jpg)
Is there any difference with this?
![Page 21: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/21.jpg)
Alternative?• There is one: put your dom-manipulation logic inside directive as
much it’s possible. Or continue doing whatever you did before =)
![Page 22: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/22.jpg)
Separation of concerns.• Previous ‘practices’ are all closely tied with this principle. This
principle is a root cause for all of them, as it seems to be in my opinion.
![Page 23: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/23.jpg)
Service to retrieve backend data also takes responsibility to set the busy-status (manipulates DOM).
![Page 24: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/24.jpg)
Separate concerns – single responsibility, etc.
![Page 25: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/25.jpg)
And your service would be testable – just inject mock spinner, or another spinner, or anything else
![Page 26: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/26.jpg)
Ruthless and Senseless empty error callbacks.
![Page 27: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/27.jpg)
Sample?
![Page 28: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/28.jpg)
![Page 29: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/29.jpg)
![Page 30: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/30.jpg)
Usage of implicitly defined objects instead of theirs ng-wrappers.• window instead of $window• event instead of $event• setTimeout & $scope.apply instead of $timeout• setInterval & scope.apply instead of $interval• etc.
![Page 31: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/31.jpg)
...or anything else as a dogma, or religion, or religious dogma
![Page 32: Angular JS And how you shouldn’t use it. Once in a blue moon… One day our customer came to us and said that he really wants to hire 3 senior developer](https://reader031.vdocuments.us/reader031/viewer/2022013012/5697bf791a28abf838c82251/html5/thumbnails/32.jpg)