Programming practices

When developing an application, especially a huge one that may take several months to finish. We tend to develop some practices and techniques that we use all throughout the development process. Some are bad, some are good. In this article, I’m going to share to you the practices that I have developed so far. Its up to you to classify if it’s a good or a bad practice.

Code Comments
Using comments to indicate where a block ends.


   }//end of do while
}//end of if


Table Truncation
Writing a separate script for truncating the tables that are affected by the current program that I’m testing. That is to easily work on a clean slate if the program didn’t work correctly. Which in turn messes up the table. What I do is to open the file in the browser, then refresh the page if anything goes wrong to start with a clean table.


Fresh Air
Breathing air from the outside environment is very effective in solving a programming problem. If you’re stuck with a problem for more than an hour already and you believe that you could have done it in just 5 minutes, then its better to get out of chair, go outside and breath some fresh air. 80% of the time you will come up with a solution, believe me.


 Firebug + console.log()
Using debugging tools like Firebug when developing applications to reduce the time spent on debugging. And using console.log to output things on the console. Perhaps most of us uses the alert() function. That’s very time consuming especially if you have to output lots, you also have to click on the OK button lots of times. And there are also other things that you cannot output using the alert() function.


Testing Folder
Also called the testing area. This is where I put files which are intended for testing code. If I’m not sure with the code that I’m writing. Or if I want to test out some other things which are not directly connected to the application that I’m working on, I put them all to the testing folder. To isolate things and to give myself the feeling that I’m working in a smaller file, with lesser code in it. Its not really easy to work on a file that has already lots of code in it.


Taking Notes
Taking down notes, making sketches in a scrap paper if you can’t directly write the code on your computer. It’s also a good place to write an algorithm. One of the most useful apps for note taking is Evernote. I definitely recommend it.


Breaking Down
Breaking down the procedural code into their respective functions. Makes it easier to copy those code into a larger file later on. But before you can break down something, make sure that you have already the working procedural code where you will base things.

function get_monthsDelayed(){


function get_surcharge(){



Database Backup
Always see to it that you are backing up the database that your application is using. Especially if you are the kind of person who is making modifications in the database structure while creating the application. Its always wise to have backups of the previous version of your database.


Code Snippets
Storing codes that you often used in a program like Snippley to save time. Retyping the same code over and over again isn’t time efficient, especially if you are to meet deadlines.

Naming Conventions
As we type more code, develop more applications. We also tend to come up with our own naming conventions. For naming files, databases, tables, fields, classes, functions, and variables. Just be sure that the names that you give to each of those are comprehensive. You can check out this post from stackoverflow if you want to learn the best practices for naming conventions:

Just make sure that you maintain the naming convention of your choice throughout a project. Be consistent.


Folder Structure
When developing applications make sure that you properly organize different files. Here’s an example of a folder structure:


Here’s a summary of the folder structure that I’m using:

  • First, make individual folders for each file types. That would be .php, .css, .js
  • If using an external library, frameworks or javascript plugins place them on a separate folder. To distinguish which file belongs to what library.
  • If the application comprises of modules, also separate the files that belong to each module. That is by creating a separate folder for each module. Common files for each module can be placed outside of the folder.
  • If using files which processes data in the background, also create a separate folder for them. You may want to further group those files using folders or by just using a naming convention to distinguish which module uses which file.


Taking screenshots  to compare outputs. When saving data into the database and you want to verify that what you have inputted is actually going to the right place, then you can use tools like Snipping Tool. A built-in Screenshot tool for Windows 7.


We don’t know everything. No matter how good you are there will always be a time that you’ll need to consult Google. If it is a specific code that you’re looking for, its always nice to study it first. Study what the code does, and how it work. Don’t just copy and paste. You won’t learn anything from that.


Give yourself a break
No matter how passionate you are there are always times when you feel like you have lost all energy to continue working on your project. That’s why its also important to have a break. Watch some movies, listen to relaxing music, play some games, or watch anime. Once you come back,  you’ll feel that you’ve been energized and you’ll actually want to work on your project as soon as possible.


There you go. As I’ve said earlier, its up for you to decide if what I’ve tackled here are good or bad practices. And as I have said in the disclaimer, I’m not in any way expert in this field. I’m still just learning just like the rest of us.
Feel free to use the comments section if you have anything to share or to ask. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: