- SalesforceChaCha
- Posts
- 💃 Keep things tidy with these 4 rules🕺
💃 Keep things tidy with these 4 rules🕺
🧹 Universal principles for "clean code" 🧹
Good morning, Salesforce Nerds! A few weeks ago, the ChaCha let it be known that we are fans of the SOLID principles! Not only are we suckers for a good acronym, we 💙 loosely-coupled code! 😍😍 But did you know that these principles are part of a broader concept coined Clean Code? 🧹🧹 Today, courtesy of our favorite Uncle Bob, let’s look at some of the universal rules of this movement!

Not again …
Agenda for today includes
Foundations
The 4 rules
Daily Principle
All the Memes
Foundations
It can’t be put any better than by the man himself:
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
Truer words were never spoke! While the book is peppered with goodies, we prepared the following 4 rules as the primary takeaways!
The 4 rules
📑 Follow standard conventions
Say it again for the folks in the back! 📣📣 Experiments can all too easily end in disaster! If there is a standard in place for your team, then follow it! If there isn’t, then create it! I’m talking through the whole stack. From things like file organization, formatting, naming conventions to things like design guidelines, architecture principles, overall coding standards. Creating a standard and sticking to it will not only make your life easier - it will make the apps you build that much more resilient!! 💪
📑 Keep it simple stupid (KISS)
I cannot stress this enough - simpler is better. Reduce complexity as much as possible! 💯 Think of it like this … every sizable system is going to have a large amount of logic and complexity. Raise your hand if you’re in an org like this! ✋ Our goal? It’s to manage this complexity by structuring our code in a way where we 1.) can find what we need easily and 2.) allows us to ONLY need to understand the small piece that’s directly affected at this time. We don’t want to have to wade through a bunch of stuff we don’t need to know right now. This is the codebase we deserve! 🦇🦇
📑 Apply the boy scout rule
The Boy Scouts of America have a simple rule that we can apply to our profession: Leave the campground cleaner than you found it. 🧹
It’s not enough to write code well. It also needs to be kept clean over time. The alternative? Code rot. So, we must take an active role in preventing this degradation! 🦸 If we all checked-in our code a little cleaner than when we checked it out, the code simply could not rot. Small changes will lead to big improvements. Change one variable name to something better, break up one big function, eliminate one duplication. Can you imagine working on a project where the code simply got better as time passed? 🤩 Can we really consider any other option professional?
📑 Always find root cause
Always look for the root cause of a problem. Otherwise, it will get you again. Fool me once …
A factor is considered a root cause if removal thereof from the problem fault-sequence prevents the final undesirable event from recurring; whereas a causal factor is one that affects an event’s outcome, but is not a root cause. Though removing a causal factor can benefit an outcome, it does not prevent its recurrence within certainty.
Basically, find the right problem and fix that. Fixing anything else may help, but it’s not root cause so you’re still vulnerable! This will help you get out of daily fire fighting!
I dig the Five whys framework for this. Simple, easy RCA’s are the key imo!
Daily Principle
"Even bad code can function. But if code isn't clean, it can bring a development organization to its knees."
and now....Your Daily Memes

maybe cuz the method is 750 lines of madness?!

actual photo of me during an RCA

🫡 give that dev a badge 🫡
What did you think about today's newsletter? |