Your code sucks. I remember the first time a mentor told me that. I was crushed. I was so focused on getting it working and done that I hadn’t taken the time to build quality into it. Shoot, I didn’t even know what that was or where to start. Thirty years later, the simple fact is all of our code needs to go through a refactoring process. It’s time to admit that your code sucks too. It’s time to clean up it up. Let’s get you on a quality path.
Over the years, I’ve seen all kinds of crappy working code. Some (or all) parts of it look like different snippets were pasted in and cobbled together to make it work. Other parts are held together by sweat, band-aids, and duct tape. The code is hard to read and understand. Oh man, you don’t want to be the one tasked with making a change in it six months from now. Nope, run for the door.
I’m going to make a big, bold statement (that’s how I roll). Ready? All code sucks until it goes through a refactoring process. Yours. Mine. Everyone. Did I shock you? It’s true.
All code sucks until it goes through a refactoring process. Yours. Mine. Everyones.As programmers, our first objective is to get it to work. In that process, we take shortcuts and put in quick fixes. Our dilemma is to balance quality with time. You only have so much time in your budget. It’s a finite cost. It’s no wonder that working trumps quality. But you can have both a quality and working codebase.
I’ve heard all the excuses throughout my career. “I didn’t have time.” “It’s good enough.” “We won’t need to update that section.” “Quality is too expensive.” “We’ve never done it that way before.” Excuses are code for “I just don’t want to do it.” Period.
Hum, I believe that quality code is worth the effort. Let’s talk about it. Be patient as you are going to want this in your workflow. Trust me.
Visualizing Your Code
Let’s do a visualization exercise. Look at the opening bridge picture. It represents your code.
It’s a bridge. It is. Right? There are planks for you to stand on. The handrails support you as you tiptoe across it. It works. Nope, it’s not pretty, but it’s functional.
Do you see opportunities to improve it?Stop building crappy code like this crappy bridge. It costs your clients, company, and you.
Imagine that something breaks. It will, as all code has bugs in it. It’s your job to step out there, quickly find the problem, and fix it. Imagine that it’s six months from now. Maybe the code made sense when you wrote it. But does it now? When you read it, does it tell you exactly what is going on and why? Is it expressive and clear without any comments? Or do you scratch your head and bang your head on the desk?
Imagine your team (or you) finds a security issue. How easy is it to patch this hole? Will the patch make the bridge (your code) stronger and more robust? Or did you just duct tape in another misfit wooden plank? What’s one more odd ball plank when it looks like crap. Wrong.
This bridge represents code. Think about your code. Monstrous functions that are more than 15 lines long feed this maze. HTML embedded into your functions are the duct taped misfit wooden planks cobbled together to get it to work. Those inline comments are screaming that your code is not readable. You are building this crappy bridge.
Meet the Clean, Quality Coding Strategy
Go do a Google search on this phrase. You will find pages of articles about clean coding. It’s not a new topic, as it’s a cornerstone of programming. But there’s this gap between the words in these articles and it appearing in your codebase. There’s this gap of training your hands to write code that complies to these principles. I get that. Who has time to learn one more thing?
Listen to me right now. Writing your code in a clean, quality manner will propel your career and reduce your costs. Period. You want to do this now. It’s the difference of having to maintain that crappy bridge and building something quickly that you can reuse and support.
Clean, quality code gives you the following:
- Readable code that tells you what’s going on and why, i.e. without comments.
- Reusable code that you use in every project to more quickly build the next thing.
- Maintainable code that empowers you to quickly find and solve the problem.
Learning how to build quality into your code and refactoring existing code helps you to work smarter. Pro Tip: Code should TELL you what is going on without comments. Working smarter means you are thinking about how to build a codebase that you can reuse over and over again with minimal effort. It’s figuring out how to get the code to tell you what’s going on. This type of code lets you find errors more quickly. It lets you extend and enhance it with less effort and time. It’s increasing your productivity. Those are good things.
It’s not vague. It’s not a mystery. You know what the function will do when you call it. You know what it will return to you. You know the expected behavior. Why? Because it does just one thing and its name clearly tells you what it will do. You know what the value is within a variable simply by its name. You don’t have to know the entire application to read just one part of it. No, you can join the team and get to work anywhere in the codebase.
That’s clean, quality coding.
Benefit to Teams
A readable, reusable, well-tested, and clean codebase is perfect for teams. Why? Anyone on the team can jump into any spot within the codebase and get to work. The code is readable and predictable. You don’t need to know the entire application to join the team. Nope, the code is self-documenting. You can figure it out simply by reading it.
Clean, quality code reduces costs for teams. The ability to move people in and out of code gives companies flexibility and maximizes productivity. These are good things.
Imagine having a codebase that is robust, readable, and well-tested. Imagine that you can reuse it on every single project. How much faster will you be at cranking out new projects with a codebase like that? How much money, frustrations, and time will it save you? Think about it.
If you keep working on the same crappy codebase or writing your code with the same crappy techniques, you are building that crappy bridge. You are not improving. You are not reducing your costs. Your client is suffering from it.
I wrote a book and workbook just for you. It took thirty (30) years of stripes on my back to learn all the lessons and techniques that I teach you in this book. “Refactoring Tweaks” gives you nine (yup there are 2 bonus ones in there) easy techniques that you can do right now to improve your code.30 years of my expertise shared with you. It’s a cable from my head to yours. These are easy. I walk you through each of them step-by-step.
In the accompanying workbook, you get to practice with code challenges. I walk through the solutions step-by-step, guiding and mentoring you on the thought processes and practical application.
It’s not some fluffy, feel-good book that will collect dust on your shelf. Nope, this bundle is meant to help you right now. It will positively impact the quality of your code and profession.
Words from Tom McFarlin
Tom McFarlin wrote the foreword and tells you the following about this book:
Within the pages of this book (and the others in this series), you’re going to find a single topic explained, demonstrated, ready-to-digest, with easy-to-apply techniques specifically designed to help you get better at what you do. It’s not hundreds of pages long, and it’s not full of jargon. It’s succinct, direct, and you will be able to apply your new knowledge by the time you finish reading.
I poured myself into this book bundle to help you. It includes real-world code examples from WordPress Core, plugins, and themes. It’s meant to help you fine-tune and practice writing clean, quality code. It’s filled with master tips and insights. You get to hear how I think about code. It’s based on proven software principles without all the fancy jargon and confusing technical blah. It’s just you and me talking about code in a clear, concise human way. It’s a cable from my brain to yours.Stop building crappy code. Get Refactoring Tweaks book bundle from @hellofromTonya. Click To Tweet
Hopefully, I’ve convinced you that building a crappy bridge is not good for your clients, company, or you. It’s time for you to learn how to write clean code. Go get my book now. Shoot, it’s only $27.99 for both the book and workbook. Don’t tell me that’s too much money. If you make money writing code, then that small amount will come back to you in heaps. Go get it now.