views:

73

answers:

1

i read some wisdom like this :

Programmers are encouraged to be careful when using by-reference variables since they can negatively affect the readability and maintainability of the code.

i make my own solution, such as give suffix such as _ref in every by-reference variables. so, if i have a variable named as $files_in_root, then i will add suffix and changes it name into $files_in_root_ref. As far my knowledge goes, this is a good solution.

So, here come the question

  1. Is there any best-practice on choosing suffix for by-reference variable in PHP coder world ? Or do you have any ?
  2. In general, how do we sustain readability and maintainability on PHP project with more then 3000 line of code ?

I hope PHP coder world has unwritten aggrement for first question, cause it will help spot a pattern on any source code.

+7  A: 

In general, if you keep the scope of a variable small, chances are that there will be no need for any pre- or suffixes. So break up your code into logical units and wrap them in classes and functions and you'll be fine.

middus
Solve the root of the problem. Very nice +1
Carson Myers
I've heard that it's possible to avoid references altogether if you use good object oriented practices and avoid global variables like the plague. I myself have never had the need to use a reference, but I'm not an enterprise-level developer so I wouldn't know the finer details.
Lotus Notes