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…


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


Using the Introduce Special Case pattern to refactor a null checking condition

Trees in autumn
Trees in autumn
Photo by the author.


View-manipulation with Angular’s reactivity

Made by Itchimonji
>>> app.component.ts

public theme: string;

constructor() {
this.theme = 'light';
}


Two important aspects of the Open-Close-Principle

Made by Itchimonji
  • Single Responsibility Principle
  • Open-Closed-Principle
  • Liskov-Substitution-Principle
  • Interface-Segregation -Principle
  • Dependency-Inversion-Principle

Itchimonji

Fullstack Software Engineer | Trained Mathematical-Technical Software Developer | Employee at Energy2market

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