Angular Refactoring Examples

Common patterns, tips & tricks, for refactoring our Angular applications

Erxk
ITNEXT
Published in
5 min readSep 22, 2020

--

Source Code: StackBlitz 🚀

Article Goal: Learn about common patterns we can potentially refactor in our Angular applications

Article Topics (What We’ll Learn)

  • Replacing component “wrappers” with :host/HostBinding/HostListener
  • Replacing BehaviorSubject.getValue() usages with more declarative techniques.
  • Replacing a Component that does everything into Container & Presentational Components

Refactoring is a technique for improving the design of existing code while preserving it’s behavior. This article focuses on concrete examples of refactoring and not so much how to refactor conceptually.

Code design can be subjective, and these examples can lean towards personal preference. We will change the design but not the underlying functionality. Either approach, refactored or not, should be valid.

Replacing Component…

--

--