Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Clean Code in PHP

You're reading from  Clean Code in PHP

Product type Book
Published in Oct 2022
Publisher Packt
ISBN-13 9781804613870
Pages 264 pages
Edition 1st Edition
Languages
Authors (2):
Carsten Windler Carsten Windler
Profile icon Carsten Windler
Alexandre Daubois Alexandre Daubois
Profile icon Alexandre Daubois
View More author details

Table of Contents (18) Chapters

Preface 1. Part 1 – Introducing Clean Code
2. Chapter 1: What Is Clean Code and Why Should You Care? 3. Chapter 2: Who Gets to Decide What “Good Practices” Are? 4. Chapter 3: Code, Don’t Do Stunts 5. Chapter 4: It is about More Than Just Code 6. Chapter 5: Optimizing Your Time and Separating Responsibilities 7. Chapter 6: PHP is Evolving – Deprecations and Revolutions 8. Part 2 – Maintaining Code Quality
9. Chapter 7: Code Quality Tools 10. Chapter 8: Code Quality Metrics 11. Chapter 9: Organizing PHP Quality Tools 12. Chapter 10: Automated Testing 13. Chapter 11: Continuous Integration 14. Chapter 12: Working in a Team 15. Chapter 13: Creating Effective Documentation 16. Index 17. Other Books You May Enjoy

The importance of clean code in personal projects

You may think that clean code is less important for personal projects, even just a tiny bit. You would be wrong if you think like this for many reasons, as set out here:

  • How can you be sure that nobody will ever be involved in the development in the future?
  • If you make your project open source, don’t you want the world to see that you are coding cleanly and be proud of this?
  • You will probably want to improve your project repeatedly. If you write bad foundations, it will be a nightmare to maintain and add new things without the fear of breaking anything. Sometimes, it is impossible to add new features because of bad code writing. In the worst cases, you will have to entirely rewrite your application. You do not want to do that.

As mentioned earlier, try to read the code you wrote a few years ago. There’s a great chance you will not be able to understand briefly what you wanted to do at that time. You may think the comments you put (if you do this) are here to help, but let’s ask two questions, as follows:

  • Who truly reads code comments?
  • What about writing code in a way that comments are unnecessary, and it is so clearly written it can be read like a book?

This is what it is all about: being able to read the source code like simple sentences without having to stop on a line to understand it. Also, to repeat what was said about clean code in teams: just because you are creating a project on your own does not mean that you won’t need external help. In fact, it is almost a certainty that one day, you will need the help of someone for something. Again, if you share the same set of common rules, it will be much easier for the helper to bring in their ideas. Even in personal moments and projects, a developer’s job is teamwork. Always.

Clean code is a mindset, and this mindset includes being proud of what we created—the taste of a job well done. It will maybe take a few years to fully understand what it is all about, and we always have new things to learn and situations we are facing for the first time. Clean code is to move toward the moment when you look at your code and tell yourself you are completely relaxed about showing your code to anybody.

As the saying goes, “write code as if the next developer to run it knows your address”. And this should also apply to personal projects because you are that very next developer.

You have been reading a chapter from
Clean Code in PHP
Published in: Oct 2022 Publisher: Packt ISBN-13: 9781804613870
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}