Narendra Dhami

My Site

Archive for July, 2009

Planning your PHP project. The easy way.

Posted by Narendra Dhami on July 7, 2009

This is something that I have personally struggled with since I became a programmer. Proper planning can make or break an application. Without it, a program can become very difficult to manage, update and scale. Your method of organization and inheritance needs to be thought out from the beginning before it is ever implemented in code. I can attest that trying to simply plan a project as you go and write each function as it comes will result in terrible code, poor functionality, higher bandwidth costs and a lack of scalability.

Now I am no project planning expert but maybe this will help out some beginners and get them pointed in the right direction. I am going to break this up into a few different sections and try to keep it as general as possible to cut back on confusion.

Step 1: Brainstorming

Grab a pen and paper (or Notepad) and start brainstorming the different features and sections your application will have. Start off with the main ones. If it is a blog then some major sections might be posting, comments and administration. Once you’re satisfied, take one section at a time and dig a little deeper. The comments section, for example, will need a submission form, spam protection, form validation and error output, etc. Keep refining this data until you are brain-dead. I would even recommend revisiting it every day for a couple days. This will ensure that you have covered all angles.

Step 2: Planning

So now you have a document (or two) outlining the different features and sections of your website. Now this is far from a spec. We need this data to be more organized and easy to read. Enter mind maps. A mind map is sort of like a web diagram that you did in grade school. They can be very difficult to do on paper (be sure you have plenty of eraser). I recommend using a program called FreeMind, which is a great program that allows you to get the process and functionality of your program on paper in a clear and concise manner.

When creating your MindMap, start off with a single node that is your software’s name. Then think of what a user can do from the home page and consult your brainstorming documents. Once you have your first level of functionality mapped out, go into each node one-by-one and input the different elements from your brainstorming documents. Repeat this process until you have everything mapped out. The software makes it very easy to move stuff around later on and has plenty levels of undo so don’t worry about simple mistakes.

Step 3: Functionality

Every advanced programmer has their own method for mapping out functionality (even if they just keep it all in their head). It is a good idea to map out each function separately (or even just the main functions). I personally recommend UML (Unified Modeling Language); there are many programs out there that use UML and provide a great environment to create your models.

Step 4: Database

The database is the backbone of your program. Mapping out a database can be difficult, however, proper database planning can cut back on hours of extra programming and stress. The best program I have found for mapping database architecture is Notepad or FreeMind. Start from your most important table (most likely your user table) and build from there. All tables usually interact with one another eventually. If you’re starting with a user table, write down all the fields, data types, etc that go with it, using your MindMap and UML diagrams as a resource.

Step 5: Execution

Start with your database. This is the foundation of any application. Build it slowly and feel free to revise as you go along (but be sure to update your database diagram). Once you are satisfied and your database is 100% (at least according to your diagram) go ahead and fill in some sample data. You can add data later as you need it.

Using your MindMap and UML diagrams as a guide, start by creating key site functions and classes. If you are creating a blog then you would have a class that handles user data and common user functionality. The same goes for comments, form validation, managing users, etc.. Once you have built as much as you can without the need for a front-end, then you can proceed.

A decent template system is always a good idea, it does take out a lot of the work involved and make it easy for non-technical designers to implement functionality within their designs. Not to mention updating and adding UI later on is much easier.

Using your template system, start to piece together the site in a logical order. It might be a good idea to begin with your administration area but that can really depend on the program and how advanced the administration is. When you get to the front-end, start with your login and session management, then proceed to sign-up, then move onto the users profile.

A good piece of advice I have heard is to code in the order in which a user would use your site or application. I interpret this loosely as this can change drastically depending on what your program calls for.

Originial Source from:

Posted in PHP | Tagged: | Leave a Comment »