---
title: "Discussion on \"Abstraction as a practice to write Clean Code\" | Hashnode"
description: "Discussion on \"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. \n\nClean code is code that is easy to understand and modify.\n\nThe book \"Clean Code\" By Robert C. Martin speaks about a lot of practices to ke..."
url: "https://hashnode.com/posts/abstraction-as-a-practice-to-write-clean-code/63399c73c03e644b5506730d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Abstraction as a practice to write Clean Code](https://pavanandhukuri.com/abstraction-as-a-practice-to-write-clean-code?utm_source=hashnode&utm_medium=feed)

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...

Oct 2, 2022 · 4 min read · pavanandhukuri.com  
Updated Oct 8, 2022  
Read the article

-   [#clean-code](https://hashnode.com/tag/clean-code)
-   [#abstraction](https://hashnode.com/tag/abstraction)
-   [#code](https://hashnode.com/tag/code)

## Written by

[Pavan Andhukuri](https://hashnode.com/@pavanandhukuri)

@pavanandhukuri · India

  
[View profile](https://hashnode.com/@pavanandhukuri)

Developer @ Thoughtworks

I am a full stack Developer with Thoughtworks with more than 12 years of industry experience. Interested in writing about tech learning, books and other general aspects.

## Responses 1

Markdown supported · ⌘↵ to post

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