liveBook · Manning

Reuse

As explained in Modern Angular

Reusability is the property of a software element being applicable in multiple contexts without being rewritten.

Reuse makes a software element applicable across multiple contexts without rewriting it. In Angular applications, poor reuse often appears as duplicated routing guards, interceptors, or business-logic directives. section 1.4.3

Duplication increases maintenance cost and prevents safe refactoring: changing one guard may require changing every copy. Reusable building blocks instead centralize behavior and reduce preventable bugs. section 1.4.3

Modern Angular expands where reusable behavior can live:

  • Use the inject function to access services, configuration, or other dependency-injection tree instances from functions, rather than requiring every consumer to be a class with @Injectable. section 1.2.1
  • Use standalone applications and building blocks when NgModules would otherwise encapsulate and share functionality through additional framework structure. section 1.2.1
  • Reuse directives for business logic that makes templates more dynamic, while sharing application state through RxJS or compatible state-management solutions. section 1.4.3 section 1.2.1

HRMS authorization

An HRMS can replace several role-checking guards or permission-checking interceptors with generalized reusable behavior. A later policy change then updates the shared implementation instead of every context-specific copy. section 1.4.3

How Modern Angular covers it

How deep it goes
Explains duplication, refactoring costs, inject-based composition, standalone architecture, and reusable directives without implementing a complete feature.
Examples
Uses HRMS authorization, duplicated role and permission checks, business-logic directives, and shared authentication or authorization events.
What it assumes
Assumes Angular familiarity, while contrasting class-based dependency injection and NgModules with newer function-based and standalone patterns.
What you can do after
Apply generalized Angular building blocks to reduce copy-pasting and make cross-cutting behavior easier to refactor.
How it connects
Connects reusability with dependency injection, routing guards, interceptors, directives, standalone components, RxJS, and state management.

Also explained in

Compare how 6 books explain reuse →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern Angular. The section links point to the parts of the book it draws on.