Open
Description
Let us discuss our new coding patterns now that we moved everything to promises:
Method 1 Linear program w/ comments
Promise.try(() {
// JSDoc
... code ...
})
.then(doSomething1 () {
// JSDoc
... code ...
})
.then(doSomething2 () {
// JSDoc
... code ...
})
.then(doSomething3 () {
// JSDoc
... code ...
})
Pro: looks linear
Cons: unit testing is harder, requires more setup
Method 2 Functional
Promise.try(() {
return fn1()
})
.then(() {
return fn2()
})
.then(() {
return fn3()
})
.then(() {
return fn4()
})
// JSDoc
fn1 = {
... code ...
}
// JSDoc
fn2 = {
... code ...
}
// JSDoc
fn3 = {
... code ...
}
// JSDoc
fn4 = {
... code ...
}
Pro: functions are broken up into smaller components. Each function can have proper unit tests and docs
Con: have to look at different areas on the page to understand full function.
Any other methods people prefer & which do you like the most?
Metadata
Metadata
Assignees
Labels
No labels