---
title: "Comment by Gopi Krishna on \"Abstraction as a practice to write Clean Code\" | Hashnode"
description: "Thanks for adding useful information here Pawan :) One small correction . in below code block we need to update third method i.e getCartForuser to deletecartIfE"
url: "https://hashnode.com/posts/abstraction-as-a-practice-to-write-clean-code/63399c73c03e644b5506730d/comment/633a8c85e594fa4ba3b9259c"
---

[Discussion](https://hashnode.com/posts/abstraction-as-a-practice-to-write-clean-code/63399c73c03e644b5506730d)

Comment [Abstraction as a practice to write Clean Code](https://hashnode.com/posts/abstraction-as-a-practice-to-write-clean-code/63399c73c03e644b5506730d)

[Gopi Krishna](https://hashnode.com/@GopiYaramothu)

[Oct 3, 2022](https://hashnode.com/posts/abstraction-as-a-practice-to-write-clean-code/63399c73c03e644b5506730d/comment/633a8c85e594fa4ba3b9259c)

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);
  }
}
```
