Slide 37
Slide 37 text
Standards & best practices
Coding style
Always favor configurables, using a helper file for constants where necessary
- You want to do this:
- Function getSomeData(page, limit) {
let constants = require(‘app/lib/constants’);
limit = min(limit, constants.pagination.MAX_ALLOWED_LIMIT);
let opts = {
page: page,
offset: (page - 1) * limit,
limit: limit
}
. . .
}
- Rather than this: limit = min(limit, 50);