A few of our favorite programming tips

Whether you’re just starting out or you’re an experienced developer, mastering the craft of programming is a challenge in and of itself. To assist in your learning, we have gathered some of the best tips (in our opinion) on how to better one’s programming skills.

Use a Vanilla Text Editor
What is meant by “vanilla” is a text editor that has no helpers or auto-complete functionality. Try doing that or you could just turn off any auto-complete functionality your editor has, and pretend you’re using something like the Windows-based classic Notepad.

Write Useful Comments
Comments are crucial. You won’t appreciate them until you leave your thousand-line script for a couple of days and return to and try and make sense of it. Useful comments make life easier for yourself and those after you who have to maintain your code.

Write meaningful, single line comments for vague lines and write full parameter and functionality descriptions for functions and methods.  For tricky logic blocks, describe the logic in words before it if necessary and don’t forget, always keep your comments up to date!

Use Meaningful Names
Never use names like $k, $m, and $test for your variables. In the future, it may be hard to remember what the variable stood for if the name doesn’t correspond properly. Good code should be meaningful in terms of variable names, function/method names, and class names.

Use Meaningful Structures
Structuring your application is very important. Don’t use complicated structures if you don’t have to. When naming directories and files, use a naming convention you agree upon with your team, or one associated with your coding standard. Always split the four parts of any typical PHP application apart from each other – CSS, HTML Templates/Layouts, JavaScript, PHP Code – and for each try to split libraries from business logic. It’s also a good idea to keep your directory hierarchy as shallow as possible so it’s easier to navigate and find the code you’re looking for.

Use Code Documenters
For large applications spanning several classes and namespaces, you should have automatically generated API documentation. This is very useful and keeps the development team aware of what’s going on. And if you work on several projects at the same time, you will find such documentation a blessing since you may forget about structures switching back and forth between projects. One such documenter you might consider using is DocBlox.

Use Version Control Software
In the old days, good development teams relied on CVS and diff patches for version control. Nowadays, though, we have a variety of solutions available. Managing changes and revisions should be easy but effective, so pick whatever version control software that will work best with the workflow of your development team. We prefer using a distributed version control tool like Git or Mercurial; both are free software/open source and very powerful.

 

Blog Categories:

Add new comment