📜 ⬆️ ⬇️

Want “holy war” - get: curly braces

All ingenious is simple.
Why I started the topic with these words: yes, because everything ingenious has long been invented and everything ingenious consists of a long forgotten genius of the old. We, who distinguish ourselves from animals by the fact that we are able to think that we are rational creatures, very often do not want to see / recognize / recognize elementary things because of our human stupidity and are inclined to follow the lead of others, without even thinking and analyzing what we are offered .
Today I will divide you into two camps.


Cause of war: curly braces


Those who program on PHP, and many others, of course, heard about the prestigious Zend, fanatics are ready to blindly believe and trust everything that is produced there and digest it in the form in which it is served.
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 by style: 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 the symbor: "curly braces"
')
What Zend offers:

class Foo
{
private function Fee()
{}

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


What Perl Offers:

Give a link to the dock, correct, okromya did not find anything
sub my_func {
...
}


What Ruby Offers:

dock
def my_func
...
end


What does Python offer:

dock
def function_name:
...

In general, there are no quotes, instead of start-bracket is used ":", which remains in the same line

What Java offers:

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

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

int emptyMethod() {}

...
}


What does Google offer:

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


I consider it illogical to make zend because



only Zend disagrees, but what opinion do you have?

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 another) formats this (my, by the way, vim, 2 styles at the same time). Express your opinion: why it is so right and so wrong in your opinion. Let's also talk about personalities, I will not give as an example that Rasmus writes “function my_func {”, and Sebastian (Bergman) - “function my_func \ n {” (in the style of zenda)

PPS Yes, I know that the topic is not one year old, and it’s like the sacred war “Linux vs Frya”, “Young vs Wines”, I want to know your logic and what you are guided by

Source: https://habr.com/ru/post/88973/


All Articles