April 2, 2014 at 6:16 am
GilaMonster (4/2/2014)
Readability is crucialBeautiful is better than ugly
Simple is better than complex
....;-)
That said, I can't figure out how (or if it's possible) to have another statement in the loop after the IF ends
I couldn't agree more that readability is critical in any language and I do write so the code is pretty. My indenting is very consistent, but I still prefer explicit terminators.
April 2, 2014 at 6:22 am
GilaMonster (4/2/2014)
It's better because now you don't have all those unnecessary starting and ending characters, and you'll avoid the arguments about where to place those brackets.
😉
Pah! Everyone knows that the only true position for braces is like this:
if (i == 1)
{
// Do cool stuff
}
:hehe:
April 2, 2014 at 6:22 am
Ok......
Guideline for python code:
"Explicit is better than implicit"
I can agree with that, it's something I argue for when teaching T-SQL. Be explicit.
Then, from the style guide for python:
Bad form:
if attr == True:
print 'True!'
Good form:
if attr:
print 'attr is truthy!'
Correct me if I'm wrong, but the first is more explicit than the second, right?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 2, 2014 at 6:24 am
paul.knibbs (4/2/2014)
GilaMonster (4/2/2014)
It's better because now you don't have all those unnecessary starting and ending characters, and you'll avoid the arguments about where to place those brackets.
😉
Pah! Everyone knows that the only true position for braces is like this:
if (i == 1)
{
// Do cool stuff
}
:hehe:
+1
Couldn't agree more. 🙂
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
April 2, 2014 at 6:27 am
paul.knibbs (4/2/2014)
GilaMonster (4/2/2014)
It's better because now you don't have all those unnecessary starting and ending characters, and you'll avoid the arguments about where to place those brackets.
😉
Pah! Everyone knows that the only true position for braces is like this:
if (i == 1) {
// Do cool stuff
}
:hehe:
Looks good to me.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 2, 2014 at 6:28 am
GilaMonster (4/2/2014)
Ok......Guideline for python code:
"Explicit is better than implicit"
I can agree with that, it's something I argue for when teaching T-SQL. Be explicit.
Then, from the style guide for python:
Bad form:
if attr == True:
print 'True!'
Good form:
if attr:
print 'attr is truthy!'
Correct me if I'm wrong, but the first is more explicit than the second, right?
Yeah, the first one is explicit. You'd think Python has been around long enough and reviewed by enough people to where they would have caught and corrected that.
April 2, 2014 at 6:57 am
To concatenate values together...
location = ''.join(['New','south','wales'])
"This will feel natural and elegant to the initiated."
and I thought readability was crucial.
Edit: The snide comments are more directed to the training course than the language. The training video punctuates examples of code with slides containing a zen-style image, a haiku and some oriental music
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 2, 2014 at 7:33 am
GilaMonster (4/2/2014)
To concatenate values together...location = ''.join(['New','south','wales'])
"This will feel natural and elegant to the initiated."
and I thought readability was crucial.
Edit: The snide comments are more directed to the training course than the language. The training video punctuates examples of code with slides containing a zen-style image, a haiku and some oriental music
I had kind of been interested in learning Python. After hearing your rants for the last couple days and the ludicrous indentation meaning something I am running away as quickly as possible. Funny how they say explicit is better than implicit and then use indentations to mean something. Talk about implicit!!!
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 2, 2014 at 7:53 am
It's not the language I have an issue with. It's different, the indenting will take some getting used to, there are odd conventions about how to handle lists and other complex data structures, but that's fine.
It's the tone of the course which has me ranting. Haiku, zen-like sayings, music, comments referring to 'the initiated' and 'uninitiated individuals', etc makes me feel like I'm watching some religious broadcast, not an introductory lesson on a computer language.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 2, 2014 at 8:13 am
Still seems quite strange. I can almost imagine the discussions in a bug tracker. "Oh I forgot to add an empty line to end the IF statement".
Or..."just added a tab at the beginning of the line so it was inside the loop".
I not a fan of stuff like that at all. Just my personal preference I suppose but that seems like an invitation to write super buggy code.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 2, 2014 at 8:15 am
But it does enforce that everybody uses the same exact code style because the style is actually part of the syntax. No arguments over:
if(SomeCondition){
DoSomething();
}
vs.
if(SomeCondition)
{
DoSomething();
}
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 2, 2014 at 9:06 am
GilaMonster (4/2/2014)
It's not the language I have an issue with. It's different, the indenting will take some getting used to, there are odd conventions about how to handle lists and other complex data structures, but that's fine.It's the tone of the course which has me ranting. Haiku, zen-like sayings, music, comments referring to 'the initiated' and 'uninitiated individuals', etc makes me feel like I'm watching some religious broadcast, not an introductory lesson on a computer language.
So you are ranting, not chanting? 🙂
Sounds like part of the training is preparing you to join a Cult.
It's one thing to make training more interesting, another to make it seem like a brain washing session.
Very distracting.
April 2, 2014 at 9:18 am
GilaMonster (4/2/2014)
Ok......Guideline for python code:
"Explicit is better than implicit"
I can agree with that, it's something I argue for when teaching T-SQL. Be explicit.
Then, from the style guide for python:
Bad form:
if attr == True:
print 'True!'
Good form:
if attr:
print 'attr is truthy!'
Correct me if I'm wrong, but the first is more explicit than the second, right?
I had a teacher who later became my first boss who argued that comparing a boolean value to true or false was redundant. If the if clause is evaluating a boolean value and your variable is boolean, then there's no need to compare it again. That worked fine with VFP, but not with SQL Server where we have no boolean data type, as bit is not the same thing.
So, using: if attr:
print 'attr is truthy!'
Would be as explicit as using:
IF EXISTS(SELECT 1 FROM Sometable)
PRINT 'Some Data'
April 2, 2014 at 9:34 am
GilaMonster (4/2/2014)
Ok......Guideline for python code:
"Explicit is better than implicit"
I can agree with that, it's something I argue for when teaching T-SQL. Be explicit.
Then, from the style guide for python:
Bad form:
if attr == True:
print 'True!'
Good form:
if attr:
print 'attr is truthy!'
Correct me if I'm wrong, but the first is more explicit than the second, right?
Could it be because True is actually instance of class bool and therefore you are not testing boolean operation, but instead testing equivalence of two classes?
April 2, 2014 at 10:07 am
Ville-Pekka Vahteala (4/2/2014)
Could it be because True is actually instance of class bool and therefore you are not testing boolean operation, but instead testing equivalence of two classes?
No, the value there is a bool. I suspect in this case the requirement for elegance and beautiful code is overriding the be explicit and readability is critical.
somevalue = True
if somevalue == True:
print("It really is true")
or
somevalue = True
if somevalue:
print("It really is true")
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 15 posts - 43,606 through 43,620 (of 66,738 total)
You must be logged in to reply to this topic. Login to reply