question abt CodingStandard recommendation?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

question abt CodingStandard recommendation?

OpenMacNews-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

hi,

i'm cleaning stuff up and reading:

        Appendix A. Zend Framework PHP Coding Standard
        -> A.4. Coding Style
        -> A.4.4.1. Class Declaration

i note:

"Placing additional code in a class file is permitted but discouraged.
In these files, two blank lines must separate the class any additional
PHP code in the file."


ok, so that's NOT recommended.  clear enuf.

so what *is* recommended? as particular example, this:

        IntroController.php:
        ==================================
        <?php
       
        function doThisRepeatedly()
        {
                blah blah
        }
       

        class IntroController extends Zend_Controller_Action
        {
                public function __construct()
                {
                }
       
                public function indexAction()
                {
                        $this->_redirect('/');
                }
       
                public function firstAction()
                {
                        doThisRepeatedly();
                }
       
                public function secondAction()
                {
                        doThisRepeatedly();
                }
        ...
        ==================================


certainly works, but, per docs, is not recommended ...

what's preferred?

richard
- --

/"\
\ /  ASCII Ribbon Campaign
 X   against HTML email, vCards
/ \  & micro$oft attachments

[GPG] OpenMacNews at gmail dot com
fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iEYEAREDAAYFAkRwE7UACgkQlffdvTZxCMayaACfZXRCnhjoZilGabYndB/Nege7
cjcAmwUbuzA0Zg7jVV4HScYzpQcQrBd4
=p+y5
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: question abt CodingStandard recommendation?

Willie Alberty
On May 21, 2006, at 12:16 AM, Richard wrote:

> certainly works, but, per docs, is not recommended ...
>
> what's preferred?

How about this:

IntroController.php:
==================================
<?php

class IntroController extends Zend_Controller_Action
{
     public function __construct()
     {
     }

     public function indexAction()
     {
         $this->_redirect('/');
     }

     private function _doThisRepeatedly()
     {
         blah blah
     }

     public function firstAction()
     {
         $this->_doThisRepeatedly();
     }

     public function secondAction()
     {
         $this->_doThisRepeatedly();
     }
     ...
==================================


Keeping the functions contained within the class definition avoids  
namespace collision problems.

--

Willie Alberty, Owner
Spenlen Media
[hidden email]

http://www.spenlen.com/

Reply | Threaded
Open this post in threaded view
|

Re: question abt CodingStandard recommendation?

OpenMacNews-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

hi Willie,

>> certainly works, but, per docs, is not recommended ...
>>
>> what's preferred?
>
> How about this:

snip

> Keeping the functions contained within the class definition avoids
> namespace collision problems.

fair nuf - makes sense.  works like a champ, too :-)

richard

- --

/"\
\ /  ASCII Ribbon Campaign
 X   against HTML email, vCards
/ \  & micro$oft attachments

[GPG] OpenMacNews at gmail dot com
fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iEYEAREDAAYFAkRw6joACgkQlffdvTZxCMZDfQCeL+spAisdAitwabp8jtnciv5g
heAAoIViWIGUlDFq7xjhNDj1mdAExdEs
=eQof
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

Re: question abt CodingStandard recommendation?

Jayson Minard (ZF)
Yes, avoid code outside classes.  Someone argued for DEFINE outside as
static constants and that may be reasonable to argue again if someone has a
case for it.

--j


On 5/21/06 3:31 PM, "Richard" <[hidden email]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: RIPEMD160
>
> hi Willie,
>
>>> certainly works, but, per docs, is not recommended ...
>>>
>>> what's preferred?
>>
>> How about this:
>
> snip
>
>> Keeping the functions contained within the class definition avoids
>> namespace collision problems.
>
> fair nuf - makes sense.  works like a champ, too :-)
>
> richard
>
> - --
>
> /"\
> \ /  ASCII Ribbon Campaign
>  X   against HTML email, vCards
> / \  & micro$oft attachments
>
> [GPG] OpenMacNews at gmail dot com
> fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (Darwin)
>
> iEYEAREDAAYFAkRw6joACgkQlffdvTZxCMZDfQCeL+spAisdAitwabp8jtnciv5g
> heAAoIViWIGUlDFq7xjhNDj1mdAExdEs
> =eQof
> -----END PGP SIGNATURE-----
>