I work with new WordPress users and developers daily . Often times, these users are frustrated with WordPress, or what they think are WordPress problems. Generally speaking their frustrations are not with WordPress per se, it’s often with the theme they are using. Sometimes it’s a commercial theme, and sometimes it’s custom-created by a developer. In either case, they have hit a wall and usually this can be traced to poor development practices.
Code For The Future and for Others!
You must always assume your code will be touched by another developer in the future! You don’t want that developer (or your future self) cursing your name. If you have written shoddy code without following best practices, you’re making life for the next developer pretty hard. The following are specific tips to develop with consideration and elegance.
Comment your code well
This is something you hear time and time again, but it’s worth mentioning again. Documenting your code will help not only other developers understand what your thought process was when writing that spiffy function, but it will also help future-you when you need to tweak something in 8 months. It’s easy to forget what you were thinking at the time the code was written or why you did something a certain way. Your future self will thank you for your present self’s clear documentation.
Use coding standards
Enqueue all the things
Become a better coder
Almost every developer, including the really, really good ones, will tell you they look at code they wrote last year, or maybe even 6 months ago to see how they could make it better based on what they have learned since. No one is born an advanced coder. Developers need to be open to change, feedback and learning.
Try to get your code reviewed by your peers if you can, or discuss with other developers their approach to solving coding problems.
Meetups are a great place to meet other developers. Find a Meetup or a WordCamp in your area. If you don’t have access to a local meetup, there are great online communities such as the Advanced WordPress Group on Facebook.
Read the Experts
Follow the blogs of people like: Bill Erickson, Mark Jaquith, Justin Tadlock, Tom McFarlin, Pippin Williamson and Paul Underwood to help cut your learning curve down and stay on top of best WordPress coding practices.
Finally, use the Theme Check and the Theme Mentor plugins to improve your code. You can use both plugins simultaneously since they offer slightly different results. They will scan your theme code and show you a list of errors, problems or recommendations, based on what the WordPress Theme Reviewers team looks at in themes submitted for the repo.