mardi 3 avril 2018

What is the best refactoring approach when multiple angular components share 70% of code

I've 4 angular (view components) components which shares 70% of the code. What would be the best approach to refactor so that code is cleaner and maintainable going forward.

Example: Following four components A,B,C and D are sharing 70% of code interms of variables used and functions. There is difference based on the how they process the data and what they render on UI(sligh variations).

**Package Structure:**
  Component A
  -componentA.ts
  -componentA.html
  -componentA.css
 Component B
  -componentB.ts
  -componentB.html
  -componentB.css
 Component C
  -componentC.ts
  -componentC.html
  -componentC.css
 Component D
 -componentD.ts
 -componentD.html
 -componentD.css

Is there any design pattern in angular which can address this?

Aucun commentaire:

Enregistrer un commentaire