Skip to content

The Explicit Construction Anti-Pattern (Promises) #5

Open
@serzero2007

Description

@serzero2007

It looks like the code for most of the methods is too complex, because of the use of the "The Explicit Construction Anti-Pattern" (http://bluebirdjs.com/docs/anti-patterns.html).

For example, instead of

return new Promise((resolve, reject) => {
   this.execute('ROLLBACK')
   .then(() => {
       self[m_transaction] = false;
       resolve(true);
    })
   .catch(error => {
       reject(error);
   })
})

one should write:

return this.execute('ROLLBACK').then(() => {
   self[m_transaction] = false;
   return true;
})

which is far simpler and easier to reason about. And performant as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions