Sunday, July 17, 2016

Making unnecessary promises?

That's a sign of cargo culting

getOptions(): ng.IPromise<IOption[]> {

    let defer = $q.defer();

    http.get('options.json').then(result => {

    return defer.promise;

That should be improved to:

getOptions(): ng.IPromise<IOption[]> {

    return $http.get('options.json').then(result => {


Read from

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.

Another good read on promises anti-pattern:

Happy Coding!

No comments:

Post a Comment