info To participate please Register or Login.

What is needed to make a good script

By Josh on August 26th, 2006. Published in PHP.

For all those who are just learning php, or even for those who already know php, or and other web language, or programing language for that matter, here are a few good tips on what makes a good script.

Simplicity
Does your script (or program) have too many excess lines of code? have you looked for ways to trim it down? Getting rid of excess code can speed up your script, which in the long run can have good benifits. Below is a example of how you could trim down your script.

Sanario: You need more than 1 thing to match something before something is executed. Code:

if ($i == '1') {
if ($x == ‘2′) {
echo (’i equals 1 and x equals 2′);
}
}

Trim it down like this:

if ($i == '1') && ($x == '0') {
echo (’i equals 1 and x equals 2′);
}

Just simple things like that can be a big benifit in the long run. As well as script loading times, it is also easy to edit. Though that is for the next step.

Errors
How easy is it to find errors in your script. If it is a long script, and it is the first time you run it, you are bound to have 1 or more errors in it. SOme things that I reccomend it that you slowy add things to the script, see if it works, and if it does, keep adding things. Though if there is a error, you know exactly what you have just done and it will be much easier to track down. Though if you have been editing a long script and can’t do that, how easy is the script to read? I talked about this is the last step. Try to make it easy for you and other programers to read so in the future. This can make like allot easier for you.

Making
Do you know what you are actually making in your script? Lets take a random script for example. I know what the end is going to be, though do i have a vaig idea what the script is going to be made up of? Well, I just have to think and write down a few things before attempting to write the script. So, I want to put everything into a array and select a random entry out of the array. Easy. Now you know how the script is going to work you can start working on it. I have attempted to make a sudoku puzzle solver, and it was really hard. I knew what the end was going to be, though when I went to start scripting, I had no idea what to write down.

Audience
Who is the script or program going to be aimed at. If it is aimed at a webmaster or computer technitican, you don’t have to make it as easy to use as if you were making it for someone who is a complete n00b at computers. A nice simple interface is the best. Only include the essencial controls. Extra controls can have a seperate page for those who are daring enough to look at them. Simple = Good!

Just remember these few steps and you will be on your way to a better script! :)

Posted by Josh.

No Responses

Express yourself. Tell us your opinion. Make a comment!

No comments or trackbacks yet.

Write your comment

Warning Spam and inflammatory comments will be deleted. If this is the first time you make a comment on Easy Webbers it will be held for moderation before being published.