Factory Pattern
·
Frontend/JS Patterns
The term “Factory Pattern” in JavaScript (and in software design in general) comes from the concept of a “factory” in real life, where a factory isa place where objects (products) are created.In the context of software design, the Factory Pattern is a creational design pattern that provides an interface for creating objects without specifying the exact class of object that will be created. 즉, ne..
Command Pattern
·
Frontend/JS Patterns
특정 작업을 실행하는 객체와메서드(아래의 placeOrder 등)를 호출하는 객체를 분리할 수 있습니다.class OrderManager() { constructor() { this.orders = [] } placeOrder(order, id) { this.orders.push(id) return `You have successfully ordered ${order} (${id})`; } trackOrder(id) { return `Your order ${id} will arrive in 20 minutes.` } cancelOrder(id) { this.orders = this.orders.filter(order => order.id !== id) retu..