Using Creational Patterns like Factory Method to refactor switch statements in Angular

Made by Itchimonji

Why do we use switch statements?


Code examples of object composition & inheritance in Angular

Inheritance

>>> base.component.tsexport class BaseComponent implements OnInit, OnDestroy…


Creational Pattern — Design Patterns Series

Abstract Factory UML


Creational Pattern — Design Patterns Series

Real-life examples

  • Cell division
  • Product manufacturing: new products often differ from their predecessors in only a few respects (cell phones, tablets, laptops, …)
  • Car production: with different extras (color, interior, rims, …)

Meaning

  • Specification…


Creational Pattern — Design Patterns Series

Real-life examples

  • Things that do not require any arbitrary order
  • SQL builder
  • Building a house
  • Burger occupy
  • Automotive industry: building a car

Meaning

  • Creation of complex objects according to a construction plan
  • Separate handling of mechanisms of…


Creational Pattern — Design Patterns Series

Real-life examples

  • Single resource shared by different users: Shopping cart, parking…


Creational Pattern — Design Patterns Series


Patterns for facilitating a software developer’s daily programming

“Auenwald” in Leipzig


A useful technique for writing a mock service for your test harness and for running your application in a full mock mode

  • Starting a test suite is much faster and more efficient than running the whole Angular application. Using smoke tests every time you changed your code isn’t a very efficient way to check if something is broken. “Test-Driven Development by Example” by Kent Beck is a great book where all these advantages of using a test harness are described.
  • Code refactoring (also a good book by Marting Fowler) is much easier with a test harness, because you just need to run your unit tests to check whether something works or is broken…


Using the design pattern Template Method to handle URL parameters of similar components with the same logic

Made by Itchimonji

Briefly explained: Routing in Angular

Itchimonji

Full Stack Software Engineer | Trained Mathematical-Technical Software Developer | Writer at CP Massive Creative

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store