Abstraction as a practice to write Clean Code
While there are many definitions of what amounts to clean code, I would personally go with its simplest form.
Clean code is code that is easy to understand and modify.
The book "Clean Code" By Robert C. Martin speaks about a lot of practices to ke...
pavanandhukuri.com4 min read
Thanks for adding useful information here Pawan :)
One small correction . in below code block we need to update third method i.e getCartForuser to deletecartIfExists
async function clearCartIfAlreadyExists(userId: string) : Promise<void> { const existingCart = await getCartForuser(userId); await deleteCartIfExists(userId, existingCart); } async function getCartForuser(userId: string): Promise<Cart> { return await getCartForuser(userId); } async function getCartForuser(userId: string, existingCart: Cart): Promise<Cart> { if(existingCart) { await cartService.deleteCart(userId); } }