Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

ts Template pattern

/*
The Template Method pattern is a design pattern lets you define the 
skeleton of an algorithm in an operation, deferring some steps to subclasses.

For example you want to make a pizza and you want to make it with 
tomato sauce, cheese and ham but you don't want to repeat the same 
steps for every pizza you make so instead you can define the steps 
in a template method and then you can use it to make different pizzas.

The Implementation will be like this
*/

class Pizza {
  public makePizza() {
    this.prepareDough();
    this.addSauce();
    this.addToppings();
    this.bake();
  }

  public prepareDough() {
    console.log('Preparing dough...');
  }

  public addSauce() {
    console.log('Adding sauce...');
  }

  public addToppings() {
    console.log('Adding toppings: cheese, ham, mushrooms');
  }

  public bake() {
    console.log('Bake for 25 minutes at 350');
  }
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: group list into sublists python 
Typescript :: Unhandled promise rejection: TypeError: ImagePicker.requestMediaLibraryPermissionsAsync is not a function. 
Typescript :: 4. In order to have proper integration of the pulse current it is desired that 
Typescript :: localstorage getitem angular 
Typescript :: nest cache 
Typescript :: vue router popstate 
Typescript :: change css to scss in angular online 
Typescript :: what version of python supports kivy 
Typescript :: Get the Post Categories From Outside the Loop 
Typescript :: which of the foolowing ia an element of pallette that holds multiple elements of nspecific purpose 
Typescript :: typescript style guide 
Typescript :: typescript initialize object 
Typescript :: list pop multiple elements python 
Typescript :: Line 23:12: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images 
Typescript :: How to separate two similar names from two lists in Python 
Typescript :: .net framework core scaffhold exists table 
Cpp :: ue4 iterate tmap c++ 
Cpp :: #include<bits/stdc++.h 
Cpp :: platform io change baud rate 
Cpp :: how to sort a vector in reverse c++ 
Cpp :: clear buffer memory in c / c++ 
Cpp :: c++ bold text 
Cpp :: reverse sort cpp 
Cpp :: c++ edit another processes memory address 
Cpp :: strcat without using built in function 
Cpp :: C++ sqlite open file in other directory 
Cpp :: count function vector c++ 
Cpp :: stl for sorting in c++ 
Cpp :: priority queue c++ time complexity 
Cpp :: prime number program 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =