Class 2 KRM Clean Code
Class 2 KRM Clean Code
Names…
Enhancing Code Readability Through
Effective Naming
• Why It Matters:
• Easy to Understand: When names are clear, you don’t need to guess what they are used
for. You can understand the purpose of the code quickly.
• Easier to Work With: If you or someone else needs to make changes to the code later,
it’s much easier when the names are descriptive.
• Better Teamwork: Good names help everyone on the team understand the code, even if
they didn't write it themselves.
Use
Pronounceable
Names..
Pronounceable Names: Use
names that are easy to say out
loud. This makes it easier to
discuss your code with others
and reduces mistakes.
# © 2024 Samarth Amrute. All rights reserved.
Example..
• Problem: cnt is hard to pronounce and
understand quickly.
• Benefit: itemCount is easy to say and
understand. It clearly describes what the
variable represents.
• Why It Matters:
• Easier Communication: Pronounceable
names help when you need to explain your
code to others.
• Reduced Errors: Names that are easy to
say are less likely to cause
misunderstandings or mistakes in coding.
# © 2024 Samarth Amrute. All rights reserved.
Avoid Encodings and Mental Mappings
Avoid Encodings:
Don’t use abbreviations
or shortcuts that make
What Does This
you think hard to figure
Mean?
out what they mean.
Use full, descriptive
names instead.