A dependency can save implementation time while adding interfaces, behaviors, and integration points that your system must accommodate. Its surface area includes ongoing obligations such as security patches, breaking changes, deprecation, and debugging code you may not call directly. section 4.3.1 section 4.3.2
When weighing a dependency, ask:
- Does it deliver real business or technical value, or mainly move code out of your repository? section 4.3.1
- Is its convenience worth the likely maintenance and debugging burden? A small, simple function may not justify a broad dependency; complex work such as cryptography or parsing may. section 4.3.1 section 4.3.2
- Does a change combine multiple concerns? Separate refactoring from feature work when possible; large batches multiply review surface area and rework. section 6.2
Figure 4.5 Importing an entire library with multiple capabilities to service one business need.
Shows how an entire library may be imported to meet a single business need. section 4.3.2
Listing 4.7 A simple validate email function
function validateEmail(email: string): boolean {
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return regex.test(email);
}
A short email validator illustrates when a small requirement may need only a few lines of auditable code. section 4.3.2
