Try rereading the readable code [Package information into the name]

books

It's a classic that I've read on and off several times, but I thought I'd write this article to reflect on what I've read and share my thoughts on it.

I'll basically write one chapter per article whenever I feel like it. I'll also write the chapters in the order that I feel like it.

I have written my observations by picking out the parts of each chapter that I found interesting, so there may be some missing section numbers.

Choose clear words

Around here,Decide the length and format of the name, and give it a specific, not abstract, name., that's what it means.

I would like to standardize on camel case and kebab case, and also use more appropriate English words.

"GetPage()" alone doesn't provide much information like where and how to get it, so for example, if you want to get it from the internet, you should use "DownloadPage()".

When retrieving data from the local cache or from the database, I would probably write FromLocalCache or FromDB, but it would be convenient if I could express it in one word.

I can't think of an appropriate word right away, but when it comes to cache, I guess something like "retrieve" would be useful.

In a DB, it would probably be something like select from SQL...I don't think this is appropriate...

It tests your English vocabulary. But if you write a fair amount of code, you'll get used to it.

Use concrete names over abstract names

There is a command option called –run_locally. This option has the following roles and features:

  • Debugging information output
  • Slow operation

I didn't use this option because performance is important when using remote servers.So, locally.

I feel like the way you use words is not essential. So,

--extra_logging is betterDirect and clear,is what they said.

Add information to a name

Add units (elapsed_ms) and give meaningful names to important parts., that is.

Maybe it would be better to make it a parsedUrl instead of just a url.

Determine the length of the name

When I name variables, I tend to give them long, easy-to-understand names, but it seems that an "appropriate" length is important.

  • If the scope is small, it is better to have a short one.(It should be around 3 lines, and if it's easy to understand, even a single character would be fine.)
  • Long names themselves seem to work fine with the IDE's completion feature.
  • If you want to omit it, it's okay if it's a common name.(string → str is OK. BackEnd cannot be BE.)
  • Remove obvious words(ConvertToInt would also be fine as ToInt.)

Communicating information through name formats

This should be fine if you follow the rules, but you should make sure constants are in uppercase, etc.

summary

This ended up being more of a summary, but no matter how many times I read it, there are still some things I wonder if I got right.

I would like to read it over and over again and imprint it in my head so that I can use it when I write code. See you!

comment

Copied title and URL