🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: mailing.www.php-dev
Article #2

All PHP programmers: Follow code convention for pvt, prt and pub declaratiosn

#2
From: alavoor
Date: Fri, 29 Jun 2001 23:45
58 lines
3933 bytes
Hello:

I follow this code convention and I recommend that all the PHP
programmers follow the same to remain consistent.

PHP scripting language provides object oriented features through the
class keyword. Features like public, private and protected will be
supported in the future release (they
are in TODO list). In the meantime, you can use the following coding
conventions to distinguish between private, public and protected
variables:

   1.All private variables and functions always start with underscore
"_" followed by lowercase letters like var $_myvar;

   2.All Protected variables and functions always start with "_T"
followed by lowercase letters like var $_Tmyvar;

   3.All Public variables and functions do not start with underscore "_"
like var $myvar;

   4.All variables and functions always start with lowercase letter (no
uppercase) like var $_myvar; and NOT like var $_Myvar;

A sample class below:-

class someabc {
        var $_conn;                     // Private variable
        var $_Tmyvar;                   // Protected variable
        var $connMYCONNECTION;          // Public variable
        var $connToDb;                  // Public variable
        var $myvar3;                    // Public variable
        var $myvarTHISTEST;             // Public variable

        function _foofunction() {}      // Private function
        function _Tfoofunction() {}     // Protected function
        function foofunction() {}       // Public function
}


The private, protected declarations provide the encapsulation and
data-hiding. But you must consider the following disadvantages of
encapsulation:

  1.   Encapsulation usually requires more code, hence it sacrifices
performance especially for scripting languages like PHP

  2.   Encapsulation requires lots of Set/Get methods for
private/protected properties.

  3.   Since encapsulation unneccessarily increases the code size, it is
not recommended for scripting language like PHP.

  4.   You can enforce a good degree of encapsulation by using the
coding convention suggested above.

See also my PHP-HOWTO doc at http://www.aldev.8m.com  mirror
http://aldev0.webjump.com
Technical Details
Message-ID: <3B3D13E4.466FD3D6@yahoo.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fce7d,96d8b970768ca3e7,start
X-Google-Attributes: gidfce7d,public
X-Google-Thread: f8095,96d8b970768ca3e7,start
X-Google-Attributes: gidf8095,public
X-Google-Thread: 1148a8,96d8b970768ca3e7,start
X-Google-Attributes: gid1148a8,public
X-Google-Thread: 10f92b,96d8b970768ca3e7,start
X-Google-Attributes: gid10f92b,public
X-Google-Thread: f9981,96d8b970768ca3e7,start
X-Google-Attributes: gidf9981,public
X-Google-Thread: 10ce1c,96d8b970768ca3e7,start
X-Google-Attributes: gid10ce1c,public
X-Google-ArrivalTime: 2001-06-29 16:45:58 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail
Message-ID: <3B3D13E4.466FD3D6@yahoo.com>
From: alavoor <alavoor@yahoo.com>
X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2 i586)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: mailing.www.php-dev,php.general,alt.php,ba.php,de.comp.lang.php,fr.comp.infosystemes.www.auteurs.php
Subject: All PHP programmers: Follow code convention for pvt, prt and pub 
 declaratiosn
Content-Type: text/plain; charset=iso-8859-2
Content-Transfer-Encoding: 7bit
Lines: 61
Date: Fri, 29 Jun 2001 23:45:59 GMT
NNTP-Posting-Host: 24.221.230.253
X-Complaints-To: abuse@earthlink.net
X-Trace: newsread2.prod.itd.earthlink.net 993858359 24.221.230.253 (Fri, 29 Jun 2001 16:45:59 PDT)
NNTP-Posting-Date: Fri, 29 Jun 2001 16:45:59 PDT
Organization: EarthLink Inc. -- http://www.EarthLink.net
X-Received-Date: Fri, 29 Jun 2001 16:43:42 PDT (newsmaster1.prod.itd.earthlink.net)