Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Is This Use of Brace Indentation Discouraged?


  • Please log in to reply
38 replies to this topic
  • Guests
  • Last active:
  • Joined: --

Never listen to an Anonymous Coward.

F*** YOU!

FUNNY

BoBo¨
  • Guests
  • Last active:
  • Joined: --
Fun is something we're happy to deal with! :D
Enjoy 8)

Tuncay
  • Members
  • 1945 posts
  • Last active: Feb 08 2015 03:49 PM
  • Joined: 07 Nov 2006
@Anonymous Coward

Feel free to do these...
If FeelDoThis
{
    MsgBox, Never do this...
    CoolPoints := 0
    isValid := True
}
Else
    MsgBox, ...or this...

If ( Index3 = 0
        OR (Index > 0 AND Index2 < 0) )
{
    MsgBox, May feel do this ...
    CoolPoints = 0
    isValid := getContent()  = "" ? False : True ; 0 is False.
}

Also feel free to do these:

if (DoThis) {
   MsgBox, Do this...
   CoolPoints:=1
} else {
   MsgBox, ...or this...
   CoolPoints:=1
}


if (I && Am || Really || Cool) {
   MsgBox, Do this...
   CoolPoints:=1
}


[*:1b8bdlpu]Dont mix styles. This would be the most reason how source become unreadable.
[*:1b8bdlpu]Using "True" instead of "true" does not make any difference in readability, like "if" or "If". In doubt, use the style mostly used in forum or documentation.
[*:1b8bdlpu]Using "True" instead of "1" explains what the value stands for: A boolean "True" or "False". A "1" or "0" is not much self explanatory. On reading code later, you dont know if the value is used as a boolean or an integer.
[*:1b8bdlpu]I do always put spaces around operators. Without spaces, Its hard to read to me.
[*:1b8bdlpu]Same for "||" as an alternative for "OR". The word "OR" is more self explanatory. The special symbol "||" is some abstract and not every beginner know for what it is stand for.
[*:1b8bdlpu]Do always explain why doing something is better doing it.
I agree with lexikos post.

  • Guests
  • Last active:
  • Joined: --

:shock: Looks like he/she wanted ensure to prove Racoon right. :lol:

...BoBo...not that your comments are ever friendly or helpful...but Raccoon did NOT need to attack me...acting like I'm dumb & the code I write doesn't matter...this topic is asking how people code...I offered my opinion...I do not deserve to be called names & belittled for responding to the topic...no, no one NEEDS to follow my style...but they REALLY don't need to pick on me...I'm not a ****ing "Anonymous Coward"...I'm a Guest...

...your creation is nothing short of art.

...so, if I don't write AutoHotkey scripts for a major company...I might as well just go die, cuz I don't matter?

@Anonymous Coward

...again, calling me that is ONLY called for if I put that in the Username box...I didn't, so calling names is uncalled for...

Never listen to a bullying Raccoon.

Rhys was asking "Is This Use of Brace Indentation Discouraged?"...I replied saying "Yes"...his example & the other, actual "Brace indentation" example are both discouraged, by me...maybe not you...but I don't have to voice YOUR opinion, I voice mine & I don't need attacked for it...yes my F U post was uncalled for, but, hey, I try to be nice as long as possible, but I can only take so much....if you don't like my opinion, say that, don't say I'm dumb or an "Anonymous Coward"...or I'm not important enough to matter (if I don't write for a large company)...

It's so refreshing (not!) to see 2 or 3 other people rally around a bully (Raccoon)...

Using "True" instead of "true" does not make any difference in readability, like "if" or "If". In doubt, use the style mostly used in forum or documentation.

...I like lowercase for "if"...the capital I just looks weird, capital I looks like l, so I think a lowercase i really is more readable, plus in JavaScript, it has to be lowercase, so that's what I'm used too. I wouldn't recommend using the docs syntax, unless the person actually likes it...people should create their own style, but if they don't have one, I like to encourage mine. Why would people blindly follow the "docs style" instead of "random guest number 1's style"?...maybe I should write the docs, then people would follow my style, without questioning it?...I'm really kidding, but do you see my point?...why "follow" the docs style?...is it more "right" than "my style" or "your style"?...

Using "True" instead of "1" explains what the value stands for: A boolean "True" or "False". A "1" or "0" is not much self explanatory. On reading code later, you dont know if the value is used as a boolean or an integer.

...I never care if something is "boolean" or an "int"...I don't limit myself, a variable might start with only 2 states, but then add another feature & that var has 3 states...so I never consider anything "boolean"...again, in JavaScript vars change their "type" automatically, so I never worry what "type" a var has...

I do always put spaces around operators. Without spaces, Its hard to read to me.

...that's fine...I dislike them, you like them, that's fine...Raccoon could've said that, but instead attacked me...

Same for "||" as an alternative for "OR". The word "OR" is more self explanatory.

...again coming from JavaScript, I like the symbols...plus I'm very computer savvy, so I can understand the symbols, when a beginner might not...

Do always explain why doing something is better doing it.

...I was posting my list, not expecting every bullet point to get such a mean reaction, I could re-do my list with more explanation, but I fear, no one likes any of them anyway...even if explained more...

VxE
  • Moderators
  • 3622 posts
  • Last active: Dec 24 2015 02:21 AM
  • Joined: 07 Oct 2006

...I offered my opinion...

That may be technically true, but I don't believe that it is possible for you to be ignorant of the tone of your first post. If you had truly intended to express your opinion, you would have not ended your list with

...feel free to ignore my style & write unreadable code...

, which clearly indicates that you believe your own style exclusively results in readable code.

Case in point: you will not convince anyone that you are an innocent flaming-victim.

My advice is to drop the matter as graciously as you are able.... Feel free to ignore my advice...

Raccoon
  • Members
  • 178 posts
  • Last active: Oct 06 2014 05:58 PM
  • Joined: 02 Jan 2008
Dear "Guest",

I apologize if you took direct offense to my usage of the term "Anonymous Coward".

For one, the name "Guest" is internally synonymous with "Anonymous", and even quotes Guest posts as Anonymous.

Secondly, the name "Anonymous Coward" [Wikipedia] is a generic term that refers to someone who posts anonymously. Generally assumed to have originated from the Slashdot forums, the name has become commonly used to reference anybody who posts radical ideas or pointed opinions (such as yours), without backing them up with an identity to cite or scrutinize later on.

To simplify, opinionated anonymous posts are (technical word) cowardly and (another technical word) garbage; to be blunt. This doesn't make you a bad person.

In the future, I would be more careful on how you use the words "never" and "always" and "big red bold text". Your post was sounding of authority and importance, when these are actually what it lacked the most.
Posted Image

Need help right away? Get live support on IRC.
Already have an IRC client installed? /join #ahk

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

...your creation is nothing short of art.

...so, if I don't write AutoHotkey scripts for a major company...I might as well just go die, cuz I don't matter?

I think you misunderstood the expression. Raccoon is saying that scripting is an art, so there is no "correct" style.

Why would people blindly follow the "docs style" instead of
"random guest number 1's style"?

The docs are written by Chris, who designed the language. The style used in the docs is naturally a better fit than that of "random guest number 1," and could even be considered a standard.

I could re-do my list with more explanation, but I fear, no one likes any of them anyway...

Not true; I agree with some of your style points, but I did not agree with the way you presented them.

[*:2yvrf8i6]If a statement is written to the right of a block-begin or block-end brace, it becomes difficult to see at a glance what is inside and what is outside the block.
[*:2yvrf8i6]Putting braces at the same indent level as the If, Else or Loop they belong to arguably makes it clearer what the body of code belongs to and where it begins and ends.
[*:2yvrf8i6]The operators && and || are arguably more easily distinguished from variable and function names. They may also make for more symmetrical code, since "and" and "or" have different lengths. (Note that the operators "AND" and "OR" are actually replaced with "&& " and "||" when the script loads.)
[*:2yvrf8i6]Lower case 'if' and 'else' may feel more familiar to some programmers (i.e. I prefer lower-case, but there is no real reason to go either way.)



Raccoon
  • Members
  • 178 posts
  • Last active: Oct 06 2014 05:58 PM
  • Joined: 02 Jan 2008

Never put anything on an opening brace (or closing brace, except else on closing brace of if)...

Even the first "commandment" given here breaks standards that are considered good-practice by the author and scripters alike. 1) Comment always. A great place for comments is the opening brace in OTB style. 2) Don't forget to Return. A nice place for Return is immediately following the closing brace of a block.

^C::
{ ; Ctrl-C alternate Copy.
    code goes here
} Return

^V::
{ ; etc ...

Posted Image

Need help right away? Get live support on IRC.
Already have an IRC client installed? /join #ahk

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

1) Comment always. A great place for comments is the opening brace in OTB style.

Do you mean non-OTB? I don't like to comment next to OTB style braces as it seems to obscure them.

2) Don't forget to Return. A nice place for Return is immediately following the closing brace of a block.

I think it is misleading to use braces with labels for the same reason that return is required: the braces do nothing more than cause AutoHotkey to unnecessarily recurse. (Line::ExecUntil() recurses for each {, returning at }, but execution continues to the line after } anyway.)

  • Guests
  • Last active:
  • Joined: --

That may be technically true, but I don't believe that it is possible for you to be ignorant of the tone of your first post.

...I used never & always to be clear on my opinion of the issue, at-a-glance, you can see which way that bullet point is describing, a "never" or "always"...it's not commanding people to do those things, it's stating that "my style" is to do or not do those things, if you wanna follow my style, then it is laid out there, clearly...

If you had truly intended to express your opinion, you would have not ended your list with...

...I end every [list][/list] with something, cuz without some text there, phpBB formats an ugly amount of "blank space"...so I had to write something there...

...which clearly indicates that you believe your own style exclusively results in readable code.

...I do...whenever I copy or test code from the forum, I spend the 1st few mins "correcting" the code to my style, then test it, fix their problem, then post my "fixed code"...fixed as in, I fixed the issue the poster needed help with, but also "fixed" the formatting to my style...I do find other's code unreadable...& it's annoying always "fixing" the code I see...

the name has become commonly used to reference anybody who posts radical ideas or pointed opinions (such as yours), without backing them up with an identity to cite or scrutinize later on.

...some people on this forum, know who "this Guest" is, just by the fingerprint of my posting style (not related to coding style)...but being "attacked" (intentional or perceived) as a Guest doesn't really induce me to reveal myself...I am a long term member of this forum & I would've posted the same list logged in...I'm not posting anonymously to "hide"...although I want to hide if I'm attacked...if people call me names as a Guest, I don't want to give them my "real" (real as in "online") name to pick on me with...

In the future, I would be more careful on how you use the words "never" and "always" and "big red bold text".

...I used bold & colors to indicate "good" & "bad"...blue is good, red is bad...it's just a formatting style of a "Do's & Don'ts" list...not to "force" people my way...just a way to read & understand the list at-a-glance...

Not true; I agree with some of your style points, but I did not agree with the way you presented them.

...could you elaborate?...when I make my posts I try to make them clear, but I seem to come off "commanding" in some people's eyes...sure I would "like" everyone to follow my style, but I don't expect them too...my list is just to be clear of my style (never/always), not to command people to follow it...I know I can't make people follow my style, but at least my list is clear, if people did decide to follow it...plus my list was a direct response to Rhys, who was asking for opinions on a style...I gave a clear list, he could follow, if he wanted...

Even the first "commandment"...

...sorry if it came of as a commandment, it was meant as a clear, at-a-glance list...you could say it's the commandments of my style, but again, it's not like I'm "making" any1 follow them...

1) Comment always. A great place for comments is the opening brace in OTB style.

...the 1st draft of that sentence was..."Never put a command on an opening brace..."...but I changed "a command" to "anything" to include "commands/functions/expressions"...I'm not really oppose to "comments" on the same line as an opening brace...but I do typically avoid same-line comments (at least in some places), for example...

a:=1		;//hard to edit value
;//easy to edit value
b:=2
...see same-line comments in this case makes it impossible to hit...End, Backspace...to edit the number in var a...so I typically put comments above the line they comment...I do use same-line comments, for example to "chop off" part of a line for testing...

2) Don't forget to Return. A nice place for Return is immediately following the closing brace of a block.

...ok, not a commandment, but...1) I don't ever put "blocks" on subroutines (nor do I indent them {I indent functions, not subs})...2) if you put the return there on a function, it probably wouldn't work (not tested)...(it's outside the "block")...

I don't like to comment next to OTB style braces as it seems to obscure them.

...as I mentioned I don't currently have an opinion for or against comments on the same line as a brace, but this would be a good reason to not do it...

the braces do nothing more than cause AutoHotkey to unnecessarily recurse

...I never liked braces on labels either, but I didn't know it gave AutoHotkey a complex too...

BoBo¨
  • Guests
  • Last active:
  • Joined: --
[OffTopic]

but I seem to come off "commanding" in some people's eyes

That gaves me the idea why there was the guessing that you're a German :lol: Its not a stereotype that Germans often seen as harsh, because they are communicating in a more 'direct' way. Even Heidi Klum is acting that way :wink:. So, there's indeed the chance of a (communication) cultural aspect to think&care about[OffTopic]

[OnTopic]

...I do...whenever I copy or test code from the forum, I spend the 1st few mins "correcting" the code to my style, then test it, fix their problem, then post my "fixed code"...fixed as in, I fixed the issue the poster needed help with, but also "fixed" the formatting to my style...I do find other's code unreadable...

I totaly agree with that. My main focus is on to 'rearrange' the code to match a 'logical' pattern. A 'code map'. Looks like I'm a 'visual' guy. 8)

& it's annoying always "fixing" the code I see...

Confirmed. But - that's a "take it or leave it" - kinda thing, right? I found myself not to (be able to) analyse a block of code ("Textwüste"), as I said to myself: "to complex/weird/unfriendly/bah ... another ones deal", because it will cost me to much time to 'fix' its appearance in advance. Once done, another supporter has already delivered a result (and I'd have to restart to 'puzzle' ... :x )

Meanwhile I've adopted several coding styles from others here. I must have been a pain in the past ... :lol:

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

it's annoying always "fixing" the code I see...

Perhaps you could adjust Auto-Syntax-Tidy to your style.

my list is just to be clear of my style (never/always), not to command people to follow it

"I never do", "I always do" and "I don't" are just statements[1]; "Never do" and "Always do" are commands[2].

1. a communication or declaration in speech or writing, setting forth facts, particulars, etc.
2. to direct with specific authority or prerogative; order

1) I don't ever put "blocks" on subroutines (nor do I indent them {I indent functions, not subs})...



Oberon
  • Members
  • 442 posts
  • Last active: Jul 03 2008 11:34 PM
  • Joined: 18 Feb 2008
Damn I never realized coding standards were such a sensitive issue for people.

CodeFashionVictimBoBo
  • Guests
  • Last active:
  • Joined: --

Damn I never realized coding standards were such a sensitive issue for people.

AFAICS a style itself can't be blamed, but I might be wrong. 8)
Degustibus non est disputandum, right? :wink:

Hey, c'mon - don't even think about to talk about how I have to wear my hair :shock::lol:

TodWulff
  • Members
  • 142 posts
  • Last active: Sep 15 2013 04:16 PM
  • Joined: 29 Dec 2007
Yikes, an emotive topic, I see... :shock:

Auto-Syntax-Tidy to your style.


Thanks, Lex, for the pointer to the tool.

-t