TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-13-2007, 03:49 AM   #1 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default Tips to Improve Your Coding and Projects

I originally wrote this article over a year ago. But after going though it I fixed allot of mistakes in grammar and composition. I also added a few things.

Programming:

Plan out what you will do before you do it.
This may seem trivial, but the hour you spend doing it will save you many hours down the road. I have learned this the hard way many times. As this may seem obvious, the only reason it is such is because you just thought of it. It won’t be nearly as fresh when you come back tomorrow. I have a full guide on planning projects here.

Make your variable names as descriptive as possible.
It doesn’t matter if the variable ID doesn’t exist, if it is with a bunch of results with result_ before it, make it result_id. This will make easier for you or any future programmer to do it. I have had to work on code where everything wasn’t well named; it was a major, multi-hour pain.

COMMENT YOUR CODE!!!!
This is by far the most important one. No matter how bleeding obvious the code looks now, it won’t be in 10 days when you have a bug that needs fixing. Comment your code for other programmers and yourself. Don’t be afraid to put long comments where they are needed, they do not affect speed. Just don't go overboard, comments explain what you are doing. Don't write a small novel over what this code did to get here and its background.

If a piece of code is used allot and may be changed, make it an include.
This is one again I have learned the hard way with deadlines just hours away. An include means one change and it’s done in every file. Typing it out every time not only makes the code messier, it makes it hard to edit. Lets say your page has a header that goes into every page. You present it to the client and he finds one error. This could mean a 25 file fix up if you don’t use includes. But if the header file was an include, it is a no problem deal.

To each its own, don’t make two things in one file.
There is no crime in making allot of files for a project. If you have two different parts that are in the same process (a forums reply box and the file that actually posts it for example), use two different files.

Don’t reinvent the wheel.
You will have projects that have the same functions in part. It is not a crime to take the code from an old project and modify it, doing so gives the client better code and saves you time. I use the same code from a project I did about a year ago for a user system. Why? I use it because its rock solid code that works every time. All I would do should I remake it is rewrite the same code, possibly some bugs with it. Similar projects mean similar code, whether you take advantage of it or not.

Don’t overuse OOP
Among programming techniques, Object Oriented Programming is a pile driver. Insane power and ability, but extremely resource intensive and large. Using OOP takes a long time to process and run. The flexibility and power it provides should one be used for pieces you will reuse on large projects. If the project isn’t large, OOP may be overkill. If that piece of code doesn’t need to be reused frequently, it may not need to be an object.


Project:

Set realistic deadlines.
NEVER give a deadline you don’t think you can make, all that can do is make the client mad and you stressed. It is better to give a deadline you think you can beat, because if you make it better the client will be happier. Should you not make it early, you have time for the unexpected. The other reason you should do this is most-nighters. There is nothing harder to edit then code made by a programmer in a time crunch, even if that programmer is you. I have done most-nighters to meet deadlines before. When you are tired and running on caffeine, your code gets messier and messier to the point you can’t read what you just wrote.

Never go into a project you can’t or won’t do.
This one is bad you both you and the client. If you don’t think you can do a project, don’t try to. What will happen is you spend extra hours trying to do this, you will eventually say you can’t do this, or raise your price. The client will either leave you or never use you again and give you bad reviews. I’ve turned down many high paying projects because I did not know how to use the script they wanted modified.

Keep the client updated.
Updated clients are happy clients. I would never go back to a programmer who tries to avoid contacting me on what’s going on. I would want a programmer who messages me when I come online, telling me what’s being done. Even if it is not a complete module being finished, I still want to know it’s being worked on.

Never
compromise your price.

I’ve had clients come to me with a CMS project for $300. In a money crunch, $300 sounds awful nice, you might be almost inclined to accept. Just take into consideration what you are doing to yourself. You are working just as hard on a project for less money. When a project for a fair price comes up you must turn it down because you are busy. It doesn’t end there though, if somehow it goes public that you gave a cut rate job, there will be people left and right asking you for a cut rate job. You don’t want a reputation for that. There are people who will pay the higher price for a good job. It is better to wait for a good one to come then to compromise your pricing standards.

I have also found that the ones expecting cut rate jobs are the hardest clients to work with. A low price either means they have no experience in what it takes to make a site like they are asking for, or they just don’t care. Either way, a bad price is a warning sign of a hard to deal with client.

Don’t work for free
This could be categorized in the same place as the previous tip. But I feel it deserves its own paragraph.

Any programmer who has been in the business for a while has had many people asking for free work. Generally they are broke kids looking for a free script. They generally make promises they never intend to keep, the common ones I hear are
  • When the site makes money you will get X% of it
  • I am outsourcing you, if I like your work many paying projects will follow
  • This will look great on your portfolio. We will both become rich off of this!.
All these have problems. One and two require the unchecked honesty from the client over money. Legally speaking, he could run with your code and there is nothing you can do about it. The final one is true, but if you need to expand your portfolio, you should not do it for someone else. If you need an extra project to show clients, do it for yourself or a paying client. That way you maintain the rights to the code and can use it whenever you want.

Make your terms clear before the project start.
I have had clients mad at me to the point where they left me even though I had the upfront fee. All because I wouldn’t do an addition for free. Clients don’t know how it works, even if they think they do. You would be surprised at what clients have asked me to do for free. The best way around this is to make it as clear as you can what you will do, what you will not do and what you will charge more for. I make sure all my clients read my policies before I seriously consider doing the project. That way if something comes up you have something on your side so he had no right to get mad.

Give the client his moneys worth, always.
No matter who gets the short end of this, give the client what he paid for. If the job takes half the time you expected, he will still give you full money. But if the project took longer then expected, still do a job to its fullest. Happy clients return to a programmer that gave them what they wanted, it is good for future jobs to keep your standards high. Returning clients generally pay well because they know you aren’t a scam.

Always have an upfront
When I was just starting things to program professionally, I had a return client come to me for a project. I did multiple projects for him before, easy to work with and trustworthy. He wanted a mail script for a smallish amount of money. It was a fast job, so I didn’t require an upfront. When I finish, his paypal isn’t working, since he outsources me he has a deadline and needs to relay this to his client. He offers me hosting in return for the money, but I don’t need hosting so I decline. I then tell him since I trust him I will give him the files if he will pay me when he gets it fixed. We agree and he gets the files. He stayed in contact for about a week with excuses I didn’t really believe, but I didn’t want to start a fight. It He never replied back. I got scammed by a client who I had a rather long history with. The moral of this story is always charge upfront and never give out the work until you are payed. Even clients you trust could go bad over it. I should also add that the amount was $35. Yes, he went bad on me even with a extensive history over $35.

Happy programming!

If you like this article, please digg here
http://digg.com/programming/Tips_to_...cts_and_Coding


Find this article and others like it at http://tips.justanotherportfolio.com/
__________________


Last edited by Village Idiot : 12-18-2007 at 03:40 AM.
Village Idiot is offline  
Reply With Quote
The Following 26 Users Say Thank You to Village Idiot For This Useful Post:
adamdecaf (08-09-2009), Alan @ CIT (03-09-2008), Alex (06-19-2008), bdm (12-13-2007), codefreek (01-17-2008), danielneri (01-26-2008), gamer13 (11-09-2009), Gurnk (12-13-2007), hello-world (02-16-2009), ibndawood (12-14-2007), Jarod B (08-09-2009), Karl (12-14-2007), kevthedude (12-13-2007), localhost (08-05-2008), maZtah (12-13-2007), Mohammad (12-14-2008), Nor (12-13-2007), oMIKEo (10-02-2008), planepixel (02-02-2009), ReSpawN (12-18-2007), S:V (03-09-2008), sjaq (12-13-2007), sketchMedia (12-15-2007), sLysdal (11-08-2009), YouNeek (01-04-2008), zxt3st (11-17-2008)
Old 12-13-2007, 11:22 AM   #2 (permalink)
The Acquainted
 
Join Date: Oct 2007
Posts: 170
Thanks: 18
maZtah is an unknown quantity at this point
Default

Great read. Thanks for sharing!
maZtah is offline  
Reply With Quote
Old 12-13-2007, 12:04 PM   #3 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

Very nice read indeed.

Thank you.
bdm is offline  
Reply With Quote
Old 12-13-2007, 01:56 PM   #4 (permalink)
The Acquainted
 
sjaq's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 113
Thanks: 11
sjaq is on a distinguished road
Default

These are some great tips.

Thanks
sjaq is offline  
Reply With Quote
Old 12-14-2007, 12:22 AM   #5 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Thanks for the article, good read indeed.

one thing i will add tho, while i agree you should comment code, i believe (and was always taught) not to over comment, there isnt a single thing worse than code that is obstructed by a small novel being written about a simple function or a an echo for example, you need to implement some common sense on that.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 12-14-2007, 01:42 AM   #6 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Very nice article. In addition to sketch's reply, I recently read an interesting alternative to commenting (a trait of eXtremeProgramming, I think), whenever you need to add a comment to a block of code, add that block of code to a new function and name the function something that explains the code (like the comment would have).
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
Old 12-14-2007, 05:48 AM   #7 (permalink)
The Wanderer
 
ibndawood's Avatar
 
Join Date: Dec 2007
Location: Chennai, India
Posts: 11
Thanks: 11
ibndawood is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
there isnt a single thing worse than code that is obstructed by a small novel being written about a simple function or a an echo for example, you need to implement some common sense on that.
<!--My Expression to the above post-->
lolz...Agreed!
<!--End of Expression-->

<!--About Karl's Signature-->
thats the best explanation for commenting
<!--End of my comment about Karl's signature-->
ibndawood is offline  
Reply With Quote
Old 12-14-2007, 05:51 AM   #8 (permalink)
The Wanderer
 
ibndawood's Avatar
 
Join Date: Dec 2007
Location: Chennai, India
Posts: 11
Thanks: 11
ibndawood is on a distinguished road
Default

oh! I forgot to say..Great Post mate!
Thankz
ibndawood is offline  
Reply With Quote
Old 12-14-2007, 02:57 PM   #9 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Commenting section revised, thanks for the advice.

Thanks for the compliments all.
__________________

Village Idiot is offline  
Reply With Quote
Old 12-17-2007, 01:27 PM   #10 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
one thing i will add tho, while i agree you should comment code, i believe (and was always taught) not to over comment, there isnt a single thing worse than code that is obstructed by a small novel being written about a simple function or a an echo for example, you need to implement some common sense on that.
I once worked with someone who commented EVERY line of Javascript he wrote.
javascript Code:
<!-- assign the value of 1 to a -->
var a = 1;

<!-- assign the value of 2 to b -->
var b = 2;
bdm is offline  
Reply With Quote
Old 12-17-2007, 02:28 PM   #11 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

Quote:
Originally Posted by bdm View Post
I once worked with someone who commented EVERY line of Javascript he wrote.
javascript Code:
<!-- assign the value of 1 to a -->
var a = 1;

<!-- assign the value of 2 to b -->
var b = 2;
Pure insult of other programmers.
__________________
Necessity is the mother of invention.

My blog
Haris is offline  
Reply With Quote
Old 12-17-2007, 03:28 PM   #12 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

Quote:
allot
should be a lot.

Quote:
Always have an upfront
I disagree I feel the clients should see the code in action(php wise) before they pay, then get the code. (never do this with javascript or html, always provide screen shots if your coding someones template).
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 12-17-2007, 03:37 PM   #13 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

That means you have never been screwed by a client who decides he doesnt want to hire you after you do 10 hours of work. Without an upfront, all your work is to waste. An upfront keeps the client with you. All my clients pay an upfront and the rest after seeing it.
__________________

Village Idiot is offline  
Reply With Quote
Old 12-17-2007, 03:54 PM   #14 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
That means you have never been screwed by a client who decides he doesnt want to hire you after you do 10 hours of work. Without an upfront, all your work is to waste. An upfront keeps the client with you. All my clients pay an upfront and the rest after seeing it.
Nice assumption but false, I've never got screwed. People believe how they want to handle clients they way they want. Based on your article doesn't mean everything will follow your ways. And a waste? Not really more of another experience you can do a lot with the code tthat you created sell it and adding it to your portfolio saying that you've did that before. Unless your coding PHP as a life time goal a major business then sure why not, other then that no I feel that way isn't a need. PHP is a hobby not a job the extra money helps out some. Note I've done upfronts before and other times I do it my way it just depends.
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 12-17-2007, 04:05 PM   #15 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

Quote:
Originally Posted by Nor View Post
Nice assumption but false, I've never got screwed. People believe how they want to handle clients they way they want. Based on your article doesn't mean everything will follow your ways. And a waste? Not really more of another experience you can do a lot with the code tthat you created sell it and adding it to your portfolio saying that you've did that before. Unless your coding PHP as a life time goal a major business then sure why not, other then that no I feel that way isn't a need. PHP is a hobby not a job the extra money helps out some. Note I've done upfronts before and other times I do it my way it just depends.
Zend and other expert PHP companies won't be impressed. Some people don't take internet earnings as a hobby but live on it.

Your point is invalid. Sorry.
__________________
Necessity is the mother of invention.

My blog
Haris is offline  
Reply With Quote
Old 12-17-2007, 06:36 PM   #16 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Nor View Post
Nice assumption but false, I've never got screwed. People believe how they want to handle clients they way they want. Based on your article doesn't mean everything will follow your ways. And a waste? Not really more of another experience you can do a lot with the code tthat you created sell it and adding it to your portfolio saying that you've did that before. Unless your coding PHP as a life time goal a major business then sure why not, other then that no I feel that way isn't a need. PHP is a hobby not a job the extra money helps out some. Note I've done upfronts before and other times I do it my way it just depends.
There are a couple problems with your post
1. 99% of the projects I do are stuff I already mastered. I don't learn anything form them.

2. Most projects I do have code which is too specific to reuse in another project. They normally don't dump you at the end, so you are suck with a useless half done application. This has happened to me before, more then a year and ive never been able to resell or reuse a single line in it.

3. I don't need another project on my portfolio, it includes all I need to get business.

I program for a living, so my methods have to be more serious then someone who programs for fun. But hobby or not, why shouldn't you use the smartest methods to make money?
__________________

Village Idiot is offline  
Reply With Quote
Old 12-17-2007, 06:43 PM   #17 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

I'm not saying the smartest method is wrong, I'm saying in most situations the smartest situation isn't the choice I always choose. But I see your point.
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 12-17-2007, 06:44 PM   #18 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Any client who is not willing to pay an upfront isn't worth working with.
__________________

Village Idiot is offline  
Reply With Quote
Old 12-17-2007, 06:45 PM   #19 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

True......
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 12-17-2007, 08:48 PM   #20 (permalink)
The Contributor
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
TerrorRonin is on a distinguished road
Default

Great tips, i'll take them into account :)
TerrorRonin is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:13 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design