6-10. 여러 함수를 변환 함수로 묶기
적용 시점
절차
예시
❌Before
const countProduct = (productName: string) => { // 비즈니스 로직 }
const getDiscountProduct = (productName: string) => { // 비즈니스 로직 }
const getProductInfo = (productName: string) => { // 비즈니스 로직 }⭕After
const getProductCharge = (original) => {
const cloneObj = cloneDeep(original) // lodash
result.discount = getDiscountProduct(cloneObj.productName)
result.count = countProduct(cloneObj.productName)
result.productInfo = getProductInfo(cloneObj.productName);
return cloneObj;
}Last updated