---
title: "Discussion on \"How to write good code?\" | Hashnode"
description: "Discussion on \"How to write good code?\". There are two ways to write any code, the one that works and then there is the right way. It does not matter whether your code works or not if your code does not have proper structure no one can ever understand what you are trying to write. This blog..."
url: "https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8"
---

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

Discussion

# [How to write good code?](https://blog.tanseersaji.com/how-to-write-good-code?utm_source=hashnode&utm_medium=feed)

There are two ways to write any code, the one that works and then there is the right way. It does not matter whether your code works or not if your code does not have proper structure no one can ever understand what you are trying to write. This blog...

Dec 27, 2019 · blog.tanseersaji.com  
Updated Mar 26, 2020  
Read the article

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

## Written by

[Tanseer Saji](https://hashnode.com/@tanseersaji)

@tanseersaji · Delhi, India

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

Machine Learning Engineer

I am a software engineer specialised in Machine Learning and Artificial Intelligence with a lot of passion for learning new things.

## Responses 5

Markdown supported · ⌘↵ to post

[Paddy McCarthy](https://hashnode.com/@Paddy3118)

[Jan 11, 2020](https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8/comment/5e19ca4e32d5fad159b6854f)

> 6} Choose correct Data Types If you restrict something then check that the value is within the assumed range.

Many exploits might take advantage of giving values outside what was once thought a reasonable range. As an aside, arbitrary string length in dynamic languages such as Perl can often help.

[Tanseer Saji](https://hashnode.com/@tanseersaji)

[Jan 16, 2020](https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8/comment/5e19ca4e32d5fad159b6854f#reply-5e206aa07a1d3fcc5902babd)

Yes that's right

[Paddy McCarthy](https://hashnode.com/@Paddy3118)

[Jan 11, 2020](https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8/comment/5e19c79e32d5fad159b684fa)

> For example, canScrollHorizontally is so much better and meaningful than ScrollableX.

Context is everything. If the variable is defined in a scollability method or class, then a better name might be 'allowHorizontal' or allowHoriz or even allowH. You have to balance identifier length, and a good way of accomplishing that is to make use of **context**.

[Tanseer Saji](https://hashnode.com/@tanseersaji)

[Jan 16, 2020](https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8/comment/5e19c79e32d5fad159b684fa#reply-5e206ad932d5fad159b6e0ba)

That is a great point sir, thanks for sharing.

[Gaponenko Andrei](https://hashnode.com/@agp32)

[Dec 27, 2019](https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8/comment/5e06432b84a7ded378c9b981)

Nice to see people interested in the topic. As a fellow enthusiast, for those willing to expand on this ideas and dive deeper, I really recommend:

> Clean Code: A Handbook of Agile Software Craftsmanship, by Robert Martin

Along with his "Clean Architecture". Those are one of the best books I've ever had honor of reading. And, of course, one cannot forget about:

> Refactoring, by Martin Fowler

[Tanseer Saji](https://hashnode.com/@tanseersaji)

[Dec 28, 2019](https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8/comment/5e06432b84a7ded378c9b981#reply-5e06fd93bcc8c0ce78e91e9e)

A lot of ideas in this post was derived from Clean Code... I will check out _Refactoring_, thanks for recommending.

[Ajinkya Hingne](https://hashnode.com/@meajinkya)

[Dec 27, 2019](https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8/comment/5e062864bcc8c0ce78e90890)

Thanks for writing these basic tips which should come naturally to any developer but I see a lot of people who don't even do good-looking/consistent indentation.

[Tanseer Saji](https://hashnode.com/@tanseersaji)

[Dec 28, 2019](https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8/comment/5e062864bcc8c0ce78e90890#reply-5e06fdccbcc8c0ce78e91ea2)

Yes, these things come with practice.

[Syed Fazle Rahman](https://hashnode.com/@fazlerocks)

[Dec 27, 2019](https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8/comment/5e061251010cc49d3c1e82a6)

Nice write up, [Tanseer Saji](https://hashnode.com/@tanseersaji). 👏

[Tanseer Saji](https://hashnode.com/@tanseersaji)

[Dec 28, 2019](https://hashnode.com/posts/how-to-write-good-code/5e060705010cc49d3c1e81b8/comment/5e061251010cc49d3c1e82a6#reply-5e06fd2b84a7ded378c9c0e0)

Thanks [Syed Fazle Rahman](https://hashnode.com/@fazlerocks)
