Re: Line length and line breaking
| From: | Justin Patrin | Date: | Tue, 23 Aug 2005 16:52:57 +0000 |
| Subject: | Re: Line length and line breaking | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20549@lists.php.net to get a copy of this message | ||
On 8/23/05, Rolf van de Krol <rolf@rolfvandekrol.nl> wrote:
> Hi all, i'm in need of your advice
>
> I'm trying to develop a piece of code, following the PEAR Coding Standards
> because i want my code to be readable. But i think it is not that easy as it
> seems :(.
> I've got the following line of code which needs to be terminated at 75-85
> characters.
> $this->rootconfig[$config_keys[$i]][$config_group_keys[$i][$j]] = new
> ConfigurationItem($config[$config_keys[$i]][$config_group_keys[$i][$j]],true
> );
> If it would be like this, it won't be a real problem. It can easily be
> terminated, but the problem is, there are 7*4=28 spaces before it.
>
> $this->rootconfig[$config_keys[$i]][$config_group_keys[$i][$j]] = new
> ConfigurationItem($config[$config_keys[$i]][$config_group_keys[$i][$j]],true
> );
> How would you terminate that line of code?
>
I would say that the line length thing is more of a suggestion than a
hard and fast rule.
Also, if your code is 7 layers deep you should probably look into refactoring.
And that line of code is also very hard to read. Again, some
refactoring may be in order. Try using foreach() instead of for().
--
Justin Patrin