Search⌘ K

Introduction

Explore the concept of JavaScript modules to achieve cohesive and well-structured code. Understand how to create modules, define what to export, and import dependencies, enabling you to organize complex applications effectively and reduce coding errors.

Cohesion

Well-designed software is cohesive.

“Cohesion is when a piece of code is narrow, focused, and does one thing well.”

A good designer strives to achieve cohesion at all levels:

  1. Functions
  2. Classes
  3. And, especially, files

Characteristics of a well-designed code file

A well-designed file should contain only things closely related to each other. Related items should be together in one file, and unrelated items should be apart from each other in ...