Several stuffs should be taken care of when you are working in a team,
or writing code for public release. Those stuffs can be:
a) Code should be easily readable.
b) Code should be extendable.
Well, that's what came to my mind for now. Debugging or extending someone else's code can be the toughest and frustrating task if the previous developer have not coded keeping above two points in mind.
So, if you want to stop troubling other's and yourself of-course, then you should make hebit of writing distributable code. The terminology 'distributable code' means nothing but following a good programming practice. At first, following a programming practice may tend to be uneasy, but as you keep on working you make it a habit.
Following are some of the programming practice that can be followed.
1)Select a Coding Standard
A coding standard can be:
a) Naming conventions (for files, variables, classes, etc)
b) Setting indentation rules
c) Commenting well and documentation
2)Writing Code in OOP
Start habit of Object oriented programming. Though experts say OOP tends to be costly to an application performance. But, comparitively they are cheaper then
web developers. Object Oriented code can be easily reused and extended. Though OOP may not give performance hike but it definitely give's you the faster better code as compared to slower better code.
So, write Distributable code and help yourself and others.