Sign in
Log inSign up
"Clean Code" Summary-Part 1- Naming

"Clean Code" Summary-Part 1- Naming

Amir Anwar's photo
Amir Anwar
·Feb 1, 2017

Clean Code, the famous book written by uncle Bob (Robert C.Martin) , Is a great book to teach you to improve your coding style, transforming your bad, cluttered code, into readable, clean and maintainable code. As I continue reading the book, I can't imagine how much I benefited from it specially that I am a beginner developer..I loved it to the degree I didn't want to forget any of the principles listed in the book, so I started to make a summary for each chapter.. I am sharing this summary for anyone interested in improving his coding skills, but doesn't have enough time to read the whole book, and also because sharing is awesome :).. I hope you love it same as I did.. btw the book is free as pdf on the internet on many websites, just search google.... let's start our journey.

Part 1 Naming

Clean Code is code that has been taken care of to be descriptive and readable..

  • use intention revealing names: radius instead of r.
  • don't use abbreviations.
  • name is better than nameString (unnecessary information).
  • clear distinctions: avoid getAccount(), getAccounts(), getAccountInfo() in same class, or e.g. avoid get(), fetch(),retrieve().
  • use pronouncable and meaningfull names.
  • Serchable names ( can be found easily by search tools as per their meaning).
  • Avoid encodings (coded names).
  • minimize the usage of prefixes like addr_name.
  • Classes and objects should have noun or noun phrase names like Customer, Account.
  • Methods should have verb or verb phrase names likepostPayment, deletePage, or save.
  • Don't use cute or humourous or witty names.
  • Accessors, mutators, and predicates should be named for their value and prefixed with get, set, and is, according to the javabean standard.
  • Use names related to the solution applied like the pattern used e.g. factory , builder.
  • If not possible relate it to the problem being solved, like relate variables to address e.g. addressName, addressNumber etc..
  • Add meaningful context, like creating a class which will hold the variables that are being used in the same context, this will make the variables belong to that class and thus have contextual meaning.

Continue to Part 2-a...

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct