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:
dockdef my_func
...
end
What does Python offer:
dockdef function_name:
...
In general, there are no quotes, instead of start-bracket is used ":", which remains in the same line
What Java offers:
dockclass Sample extends Object {
int ivar1;
int ivar2;
Sample(int i, int j) {
ivar1 = i;
ivar2 = j;
}
int emptyMethod() {}
...
}
What does Google offer:
dockQuote: "
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
- 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 a queue, you get a +41 line. Nothing more - 20% of the total number of lines in the file.
- illogical: in the case of zend, the closing bracket closes the bracket, and not the logical element, the element itself seems to be “cut off”
- Why interfere with two styles in one document? (for dull ones: the bracket in classes and functions goes to a new line, in if-ah, switch-ah and so on in the same line) so decided to stand out?
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