[PHP] dev style guide

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default RE: [PHP] dev style guide

    [snip]
    They use the One True Brace Style,
    which is encouraging:

    function fooFunction($arg1, $arg2 = '')
    {
    if (condition) {
    statement;
    }
    return $val;
    }
    [/snip]

    At the risk of starting a flame/religious/holy war I find the One True
    Brace style to have some inconsistency if it is as above. The 'function'
    does not open the curly brace at the EOL, but the 'if' does. I also
    mentioned me being and old-schooler earlier today but the rules that we
    use in our (current) group always place the opening curly at the EOL.
    Also, we do not allow ternary notation. We encourage Hungarian notation,
    but do not require it if the documentation is clear.

    HTH!
    Jay Blanchard Guest

  2. Similar Questions and Discussions

    1. Character style has a little + after style
      Sometimes when I try to change some copy to a particular character style, the font won't fully change. Instead I get a small + after the style. How...
    2. Need help with Style conversion from Style object to Style key/value collection.
      I am writing a custom control that derives from the DataGrid control. I would like to apply SelectedItemStyles and ItemStyles for use in my derived...
    3. Number format German style => English style when importing CSV files into MySQL-DB
      Hi there, I'm trying to import a csv file into my MySQL database. Unfortunately the number format for the price column is formatted in German...
    4. dev style guide
      Is there a style guide for coding practices used when creating code to be shared with the community? Walter -- Ankh if you love Isis.
    5. perl style guide
      Besides the one on perldoc.com, does anyone else have any other style guides I can take a look at to get a look at feel for which one I should use?...
  3. #2

    Default RE: [PHP] dev style guide

    >At the risk of starting a flame/religious/holy war I find the One True
    >Brace style to have some inconsistency if it is as above. The 'function'
    >does not open the curly brace at the EOL, but the 'if' does.
    Yeah, that's pretty much the definition of the OTBS. :)

    I'm not sure why I find it so natural, but basically it acknowledges that
    function definitions are fundamentally different (in usage and meaning)
    than other code blocks. I like this.

    >I also mentioned me being and old-schooler earlier today but the rules
    >that we use in our (current) group always place the opening curly at the
    >EOL. Also, we do not allow ternary notation.
    Personally, I use ternary notation a lot, but I try to use it thusly:

    (condition
    ? statement 1
    : statement 2)

    The line breaks make it easier to see what's going on.

    I don't think it really matters what standard you use, as long as you
    *have one* and everyone in your group agrees that it's a comfortable fit,
    which paradoxically seems to converge on something like what PEAR uses
    anyway.

    Anecdote:
    At one time, a member of our group decided (on their own) that the coding
    style should automatically prefer printf() constructions to double-quoted
    variable interpretation, and that it should be word-wrapped to fit within
    his 80-char vim terminal. An autoconversion script was written, files were
    drastically modified to conform, and then subsequently committed to CVS.
    This is not a proper way to go about implementing a coding standard. :P

    ---------------------------------------------------------------------
    michal migurski- contact info and pgp key:
    sf/ca [url]http://mike.teczno.com/contact.html[/url]

    Mike Migurski Guest

  4. #3

    Default RE: [PHP] dev style guide

    Jay Blanchard <mailto:jay.blanchard@niicommunications.com>
    on Tuesday, August 05, 2003 1:23 PM said:
    > We
    > encourage Hungarian notation, but do not require it if the
    > documentation is clear.
    Ahhh.... /Hungarian/ notation. Now that makes sense. I *thought* there
    was something funny about "polish notation" (which as I've found out is
    a certain way of expressing mathematical equations [iirc]).

    I've found a few articles on Hungarian notation but none of them have
    been all that great. Real wordy and without good examples. Do you have
    any examples/articles to contribute?


    c.
    Chris W. Parker Guest

  5. #4

    Default RE: [PHP] dev style guide

    > -----Original Message-----
    > From: Chris W. Parker [mailto:cparker@swatgear.com]
    > Sent: Tuesday, August 05, 2003 4:33 PM
    > To: Jay Blanchard; Mike Migurski; jsWalter
    > Cc: [email]php-general@lists.php.net[/email]
    > Subject: RE: [PHP] dev style guide
    > Ahhh.... /Hungarian/ notation. Now that makes sense. I *thought* there
    > was something funny about "polish notation" (which as I've found out is
    > a certain way of expressing mathematical equations [iirc]).
    OK, OK, my math geek-ness reared its ugly head.

    Hungarian notation is waht I shoulfd have said.

    ;)

    > I've found a few articles on Hungarian notation but none of them have
    > been all that great. Real wordy and without good examples. Do you have
    > any examples/articles to contribute?
    This is what I found on the issue around the 'net...

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvsgen/htm
    l/hunganotat.asp

    http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:
    80/support/kb/articles/Q173/7/38.ASP&NoWebContent=1

    http://www.gregleg.com/oldHome/hungarian.html

    this one is short and sweet...

    http://www4.ncsu.edu:8030/~moriedl/projects/hungarian/

    walter

    Jswalter Guest

  6. #5

    Default RE: [PHP] dev style guide

    [snip]
    I've found a few articles on Hungarian notation but none of them have
    been all that great. Real wordy and without good examples. Do you have
    any examples/articles to contribute?
    [/snip]

    There is a lot to go on out there
    [url]http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=Hungarian+notatio[/url]
    n

    We have agreed on cetain types (strings are strFoo, integers are intFoo,
    doubles are dblFoo, etc.) and allow for other descriptive notation where
    standard terms do not work.

    HTH
    Jay Blanchard Guest

  7. #6

    Default RE: [PHP] dev style guide

    Just a remark but isn't it pointless to use Hungariannotation in a
    language that is by default typeless???

    Regards
    Stefan Langer
    SLanger@spirit21.de Guest

  8. #7

    Default RE: [PHP] dev style guide

    [snip]
    Just a remark but isn't it pointless to use Hungariannotation in a
    language that is by default typeless???
    [/snip]

    We use it becuase we have a group of programmers, so the notation makes
    it easier for one in the group to understand the intention of another in
    the group. The notation also helps to clear up any casting issues that
    may arise. [url]http://us2.php.net/language.types.type-juggling[/url]

    Jay Blanchard Guest

  9. #8

    Default Re: [PHP] dev style guide

    From: <SLanger@spirit21.de>
    > Just a remark but isn't it pointless to use Hungariannotation in a
    > language that is by default typeless???
    I would think that it would be the reason why you WOULD want to use
    Hungarian notation (not that I do, though).

    Even though you can take nVar and concatinate it into a string, should you?
    Maybe you should first cast it to a string, then concatinate... right?

    Using the notation would mean that'd you'd know what the varaible was
    intended to hold when it was created, even though it can be juggled into
    another type by PHP rather easily.

    ---John Holmes...

    Cpt John W. Holmes Guest

  10. #9

    Default RE: [PHP] dev style guide

    At 11:27 AM 8/6/2003 -0500, Jay Blanchard wrote:
    >[snip]
    >Just a remark but isn't it pointless to use Hungariannotation in a
    >language that is by default typeless???
    >[/snip]
    >
    >We use it becuase we have a group of programmers, so the notation makes
    >it easier for one in the group to understand the intention of another in
    >the group. The notation also helps to clear up any casting issues that
    >may arise. [url]http://us2.php.net/language.types.type-juggling[/url]
    And it helps when you get back up to speed when you revisit a project after
    a few months.
    Use of Hungarian notation has been a bit of a religious issue; use what
    works and use it consistently.

    Of course, if you come from the Flash world, it's likely a postfix (ugly
    word!) rather than prefix.

    Cheers - Miles

    Miles Thompson Guest

  11. #10

    Default Re: [PHP] dev style guide

    Actually the word is Suffix not postfix... Prefix and Suffix.


    --
    Best Regards, Phil

    Phillip Blancher
    Web Developer & Lead Graphic Designer
    < [url]http://www.ontarioweb.ca[/url] > 1-866-209-0349
    < [email]phil@ontarioweb.ca[/email] >
    ----- Original Message -----
    From: "Miles Thompson" <milesthompson@ns.sympatico.ca>
    To: <php-general@lists.php.net>
    Sent: Wednesday, August 06, 2003 2:37 PM
    Subject: RE: [PHP] dev style guide

    > At 11:27 AM 8/6/2003 -0500, Jay Blanchard wrote:
    > >[snip]
    > >Just a remark but isn't it pointless to use Hungariannotation in a
    > >language that is by default typeless???
    > >[/snip]
    > >
    > >We use it becuase we have a group of programmers, so the notation makes
    > >it easier for one in the group to understand the intention of another in
    > >the group. The notation also helps to clear up any casting issues that
    > >may arise. http://us2.php.net/language.types.type-juggling
    > And it helps when you get back up to speed when you revisit a project
    after
    > a few months.
    > Use of Hungarian notation has been a bit of a religious issue; use what
    > works and use it consistently.
    >
    > Of course, if you come from the Flash world, it's likely a postfix (ugly
    > word!) rather than prefix.
    >
    > Cheers - Miles
    >
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    >
    > --
    > This message has been scanned for viruses and
    > dangerous content by Ontario Webs MailScanner, and is
    > believed to be clean.
    >
    >

    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.507 / Virus Database: 304 - Release Date: 8/4/2003

    Phillip Blancher Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139