getOptions(): ng.IPromise<IOption[]> { let defer = $q.defer(); http.get('options.json').then(result => { defer.resolve(result.data); }); return defer.promise; }
That should be improved to:
getOptions(): ng.IPromise<IOption[]> { return $http.get('options.json').then(result => { return result.data; }); }
Read from codelord.net
Cargo Culting, unnecessary rituals. Yes, no matter how logical programmers are, they are not immune to blind faith too. Sometimes, it's because of lack of understanding of how the tool should be used. Sometimes also, the documentation is lacking.
Some programmers have too much faith in their own code, when in fact they should not be writing codes at all or should just write a minimal amount of code in the first place.
https://blog.codinghorror.com/the-best-code-is-no-code-at-all/
http://haacked.com/archive/2010/08/26/not-paid-to-write-code.aspx/
https://en.wikipedia.org/wiki/Cargo_cult_programming
Another good read on promises anti-pattern: http://taoofcode.net/promise-anti-patterns/
Happy Coding!
No comments:
Post a Comment