Raj KB Profile picture
🐦 Tweeting PHP / Symfony(🏅) • Magento(🏅) • React 🔜 HTMX/HotWire • DBA • DevOps|AWS 🔎 Go 🛠️ Building #Magento plugins / SaaS for @MagePsycho Open for 🤝

Jan 30, 2022, 12 tweets

0⃣ Clean Code Series: Variables📒🧑‍💻

It's a guide to producing readable, reusable, and refactorable software in #php #ruby #javascript #python #java, etc. - Software engineering principles, from Robert C. Martin's book "Clean Code"

(code: github.com/jupeter/clean-…)

Thread (9)🧵👇

1⃣ Clean Code Series: Variables📒 🧑‍💻

☑️ Use meaningful and pronounceable variable names

2⃣ Clean Code Series: Variables📒 🧑‍💻

☑️ Use the same vocabulary for the same type of variable

3⃣ Clean Code Series: Variables📒 🧑‍💻

☑️ Use searchable names (part 1)

💡We will read more code than we will ever write. By not naming variables that end up being meaningful for understanding our program, we hurt our readers. Make your names searchable.

4⃣ Clean Code Series: Variables📒 🧑‍💻

☑️ Use searchable names (part 2)

5⃣ Clean Code Series: Variables📒 🧑‍💻

☑️ Use explanatory variables

6⃣ Clean Code Series: Variables📒 🧑‍💻

☑️ Avoid nesting too deeply and return early (part 1)

💡Too many if-else statements can make your code hard to follow. Explicit is better than implicit.

7⃣ Clean Code Series: Variables📒 🧑‍💻

☑️ Avoid nesting too deeply and return early (part 2)

8⃣ Clean Code Series: Variables📒 🧑‍💻

☑️ Avoid Mental Mapping

💡Don’t force the reader of your code to translate what the variable means. Explicit is better than implicit.

9⃣ Clean Code Series: Variables📒 🧑‍💻

☑️ Don't add unneeded context

💡If your class/object name tells you something, don't repeat that in your variable name.

That's all for the first part of clean-code.
In the next Thread, I will add functions & classes.

If you like this thread,
✅ Follow me @rajkbnp
💕 Like it
🔀 Retweet it

Thanks 🙏

📢The second part of the Clean Code Series: Comparison is also available now👇

#tdd #ddd #solid #cleancode #refactor
More on the way (next: functions)

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling