views:

101

answers:

4

Currently, I have to work on a product, consisting of php code, to be consumed by public. And because of the nature of the work, I have to make sure it works on various servers on configuration. What is the best way of coding the product?

+2  A: 

I'm not sure I really understand what's special in your situation: the definition of "product" that you have in mind. I can think of two implications:

A: It's a product: it's shipped to large numbers of customers who have formal support agreements. Shipping a defective product is going to cause us serious problems. If there are defects then we need to be able to identify the problem easily, and remotely without hands-on access to the machine where the problem is showing-up.

B: It needs to be portable, it will be run on a wide variety of platforms.

I see the following things as especially important:

  1. Good testing. You need to have strong assurance that what you ship is solid. You need to pay careful attention to your strategy for ensuring that what you ship is good. As you value portability you need to be able to run tests on several platforms. This probably implies that you have some kid of automated regression test suite. If you adopt a Test-Drived Development approach you may find you are building a good set of regression tests as you go.
  2. Good error reporting. When your code hits errors it must report then clearly so that your customers have useful error symptoms they can report to the support team.
  3. Code defensively. Make sure that every return code is checked, make no assumptions. Your product runs in a variety of different envrionments - weird things happen. It's far better to fail with a useful error message than stumble into undefined behaviour.
djna
@djna thanks this's helpful +1
justjoe
@djna i would like to know more about 'code defensively'. do you have any reference about this topic ?
justjoe
+2  A: 

So I hope my understanding of your question is correct.

I also work on a product that is consumed by the public. The best you can do is build for the most generic setups possible. Develop on commodity hardware using standard server configurations. Try to turn off as many extra modules as you can from the start. Chances are, there's going to be at least one user that has no idea why they're getting a "PDO Error".

As for testing, get a cheap account with GoDaddy, one on Linode, Hostmonster, etc. Test your app EVERYWHERE you can. Make sure it installs cleanly and your documentation accurately reflects the function of your product.

The last thing consumers want is to purchase a product that doesn't work with their system. Testing in many environments will benefit you in the long run.

Hope this helps!

mattbasta
+3  A: 

It helps using a framework where various things are already taken care of.

aromawebdesign.com
+2  A: 

A few things that come to mind:

  • Use Version Control
  • Follow established design patterns and principles
  • Document your code
  • Write UnitTests
  • Use Continuous Integration

Suggested reading: Quality Assurance in PHP Projects

Gordon