The importance of thinking ahead

I remember my first commercial project  a simple CMS (Content Management System) which helps accountants to communicate with their customers more easily. Main objective was to create simple inner platform in which registered users could upload their checks, indents, drafts, expenses and other stuff. In addition, accountant which registers his users can view the documents, change their category, status or he can create other necessary forms and documents for the client.

It seemed to be very simple especially when the design was ready for use –  I just needed to copy the styles file to another location. However, I made really big mistake by going straight to the job. I did not make any plans what I should make first, what I should do second and so on. The only notes were about database tables and their fields.

The start of the project was quite successful, because it was not hard to make a login form and to block other users from viewing private information. At that time I chose to include all necessary files by running case/switch sentence.

At that point I did not care about other functions which I needed to program later and everything started from there. After making other pages I understood that when you submit form and if you want to get data by $_POST method, you need to declare variables with $_POST at the page you specify form. For example, if you make action=”index.php”, you would not get variables in the included file accountant.php unless you include it without base url name. What do I mean?

You can include file by writing two types of paths:

1) include(“http://www.example.com/library/file_one.php”);

2)include(“library/file_two.php”);

In the first case you even would not get the same variables from index.php to file_one.php because you make external include – variables scope doesn’t go along all document. All variables that were defined at index.php will only be declared there, and it is the same with file_one.php. So if you use $element in index.php, there is no such thing in file_one.php when you include this file as shown in the example.

On the other hand, more appropriate include is made by second option and both files have the same variable scope. If you have declared $element in index.php and then included file_two.php, you could easily use $element value.

This problem and many others made me sick later because most code was written in that way and I took all data from submitted forms to my index.php which become very long at the end. Other problem was the lack of functions. There have not really been any functions in that project – I just copied and replaced necessary variable names.

You can imagine how hard it was to finish the project. It was hard not only because the code was written really bad, but because I knew that it was written bad and my conscience talked to me every time I edited the documents. However, it was really late to recreate the system because I had only two weeks to make everything clear and working. At that time two week for this kind of CMS was really eight hours of hard work and nerves.

So plan everything, make notes and try to write down as much as you can when you start a new project. By making notes you will also know what to do next and there would not be any waste of time thinking of what I could do next. Moreover, you will have already everything in your mind, so there should be any surprises at the end of development.

Leave a comment