Chapter 12. Best practices

 

This chapter covers

  • Benefits of simplicity in your code
  • Structuring your app’s files
  • Using the npm shrinkwrap command to lock down dependency versions for reliability (and the benefits of doing so)
  • Avoiding installing modules globally

It’s time to bring this book to a close.

If this book were a tragedy, we’d probably end with a dramatic death. If it were a comedy, we might have a romantic wedding. Unfortunately, this is a book about Express, a topic not known for its drama and romance. The best you’ll get is this: a set of best practices for large Express applications. I’ll do my best to make it romantic and dramatic.

With small applications, organization doesn’t matter much. You can fit your app in a single file or a handful of small files. But as your apps become larger, these considerations become more important. How should you organize your files so that your codebase is easy to work with? What kind of conventions should you adhere to in order to best support a team of developers?

In this final chapter, I’ll do my best to share my experience. Very little of this chapter will be strictly factual; I’ll lend opinions to the unopinionated philosophy of Express with respect to what it takes to build a medium-to-large application with it.

12.1. Simplicity

12.2. File structure pattern

12.3. Locking down dependency versions

12.4. Localized dependencies

12.5. Summary