Clean code is the cornerstone of every successful software project. As a developer, your ability to write clean, maintainable code is crucial for t...
For further actions, you may consider blocking this person and/or reporting abuse
Your 'Performance Optimization' example is wrong / nonsensical....
Good I was about to comment about the comments section, but you was faster π. A redundant comment could became a problem because with time people tend to update the code and forget to update the comments, so I would avoid comments on code and try to make the declarations more comprehensible as possible.
But @mahabubr, very good article anyway, congrats.
Great post! In my experience we need more people taking clean code seriously and helping raise the tide π
Often when I talk to people about these type of things I get responses like βI donβt care about writing beautiful code, we have real work to doβ, so I feel like itβs always important to focus on why these principles are valuable. They help us build systems which can adapt to change more easily. I find that most of the value comes from just putting in a little effort with SRP and variable naming βοΈ
I don't agree with the magic numbers example. I don't understand how using a constant violates clean code principles. In your bad example, you use TAX_RATE. If the tax rate changed, you would have to go through your function and update it in multiple spots. In a large code base, there is the risk of missing a value.
I agree with the other devs regarding your comment examples. I personally only add comments to add clarity for a decision made that isn't easy to articulate in the code itself. The code itself would be written in a way that explains its function.
Since taxrate is stored in a constant variable, that will only take a single change, change the taxRate variable to another value and that's all, my opinion though.
Please change the name of this page to "Mastering Clean Code: Essential Practices for Javascript Developers". That would make it a more clear and descriptive name.
Maybe put the language version in the text at the top of the page. So instead of "JavaScript", it could say, "JavaScript (ECMAscript 2023)". That may help future readers understand the context, depending on future additions to the language.
Thank you for writing this, Mahabubur Rahman, and commenters.
I personally like seeing developers applying clean code principles, so I hope my feedback finds you well. Your source code lacks some highlighting. Would be neat to see that next time.
Also error handling and asynchronous are not really consistent. The then/catch example appears to be ok for errors but not for asynchronous operations? It also hides the fact that there can be good reasons to choose one over the other. I agree that it can get messy if nested too much, but this is not shown in your example.
thank you for share your prospective
What a great post! Every developer should follow these instructions. Clean code is the best prerequisite for a great project.
Thanks, now I know how to write clean code
thank you for share your prospective