Want holy war - get: curly braces

    All ingenious is simple.
    Why did I start the topic with these words: yes because all ingenious has long been invented and all ingenious new consists of a long forgotten ingenious old. We, distinguishing ourselves from animals in that we are able to think that we are rational creatures, very often because of our human stupidity do not want to see / recognize / realize elementary things and tend to follow the lead of others without even thinking and analyzing what they offer us .
    Today I will divide you into a simple thing in two camps


    Reason for war: curly braces


    Those who program on PHP, and many others, of course, have heard about the famous Zend, fanatics are ready to blindly believe and trust everything that is produced there and digest it in the form in which it is presented.
    Our "ideal" zend and its group (I have nothing against the people who write it - because they deserve respect for their work and many years of experience) offers a concept on styles: http://framework.zend.com/manual/en/coding -standard.coding-style.html . Everything would be fine, but I cannot agree with some points of this document.
    And here’s what the cheese is: “curly braces”

    What Zend offers:

    class Foo
    {
        private function Fee()
        {}

        private function Fee()
        {
            if (debug) {
            }
        }
    }


    What Perl offers:

    a link to the dock, adjusting okromya that nothing found
    sub my_func {
        ...
    }


    What Ruby offers:

    dock
    def my_func
        ...
    end


    What Python offers:

    dock In general, there are no quotes, instead of a start-bracket a ":" is used, which remains on the same line
    def function_name:
        ...



    What Java offers:

    dock
    class Sample extends Object {
        int ivar1;
        int ivar2;

        Sample(int i, int j) {
            ivar1 = i;
            ivar2 = j;
        }

        int emptyMethod() {}

        ...
    }


    What Google offers:

    Doc
    Quote: " An opening curly brace should never go on its own line; a closing curly brace should always go on its own line. " - which means that you should never separate and wrap the opening bracket on a new line, but it should always be on the same line (add: on the same line as the logical element)
    CalculateSampleCovariance <- function(x, y, verbose = TRUE) {
        ...
    }


    I consider illicit decisions of the zenda because

    • inconvenient: it adds extra time, if you have a file of 200 lines, contains 1 class and 40 methods, then in the case of formatting the zend, you get +41 line at the output. Neither more nor less - 20% of the total number of lines in the file.
    • illogical: in the case of the zend, the closing bracket closes the bracket, not the logical element, while the element itself seems to be “torn off”
    • why bother with two styles in one document? (for the dull: the bracket in classes and functions goes to a new line, in ifs, switches, etc. on the same line) so the zend decided to stand out?


    only Zend disagrees with this, but what is your opinion?

    PS a huge request: do not give as arguments that Checkstyle in phpUnderControl considers this a mistake, because it is written in the dock of the zend or my editor (zend or the other) formats it like that (mine, by the way - vim, does not support 2 styles at the same time). Express your opinion: why is it so right and so wrong in your opinion. Let’s take a look at personalities as well, I won’t give an example that Rasmus writes “function my_func {”, and Sebastian (Bergman) writes “function my_func \ n {” (in the style of Zend)

    PPS yes, I know that the topic isn’t one year, and it’s like the holy wars of “Linux vs Frya”, “Young vs Vin”, I want to know your logic and what you are guided by

    Also popular now: