tag:blogger.com,1999:blog-6444609270251748954.post6896555874128965621..comments2024-03-11T23:12:21.225-07:00Comments on Delphi Code Monkey: Indentation Holy Wars.Warrenhttp://www.blogger.com/profile/04053407632823479165noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-6444609270251748954.post-84265748349479191222012-08-28T20:11:08.986-07:002012-08-28T20:11:08.986-07:00Indenting was lost in my above comment. The "...Indenting was lost in my above comment. The "DoSomethingElse;" should have been.Louis Kesslerhttps://www.blogger.com/profile/11704667321407909489noreply@blogger.comtag:blogger.com,1999:blog-6444609270251748954.post-27145919232080317022012-08-28T20:09:15.314-07:002012-08-28T20:09:15.314-07:00Warren:
I almost use what you use. Only differenc...Warren:<br /><br />I almost use what you use. Only difference is I do:<br /><br /> end <br /> else begin <br /> DoSomethingElse;<br /> end;<br /><br />The else is not part of the previous block that is ended by the "end". And this way, the else block is lined up with its own "end".<br /><br />That last statement might be my reasoning, but the reason why I do this is because that's the way I've always done it.<br /><br />Louis<br /><br />(Just added your blog to my RSS feed list. It's always nice to find out about another Canadian Delphi user - we're a rare breed.)Louis Kesslerhttps://www.blogger.com/profile/11704667321407909489noreply@blogger.comtag:blogger.com,1999:blog-6444609270251748954.post-24626362081733795762012-06-25T15:02:37.736-07:002012-06-25T15:02:37.736-07:00Thanks for sharing, Anonymous!
WThanks for sharing, Anonymous!<br /><br />WWarrenhttps://www.blogger.com/profile/04053407632823479165noreply@blogger.comtag:blogger.com,1999:blog-6444609270251748954.post-9343009015012725152012-06-25T13:49:10.886-07:002012-06-25T13:49:10.886-07:00I started with a Pascal Modified Banner Style base...I started with a Pascal Modified Banner Style based on the following look:<br /><br /> IF FileExists (fn) THEN<br /> ___BEGIN<br /> ___RESULT := TRUE;<br /> ___EXIT;<br /> ___END<br /> ELSE<br /> ___FOR i := 1 TO 5 DO BEGIN<br /> ______Sleep (1000);<br /> ______IF FileExists (fn) THEN EXIT;<br /> ______END;<br /><br />The purpose was that if you glance at the code, you see it is immediately an IF...ELSE block.<br /><br />When I have an IF, FOR, WHILE, etc. the next line is indented and that indentations stays until that IF, FOR WHILE block is ENDed.<br /><br />You might say the IF, FOR, WHILE, etc. are sort of tabs.<br /><br />HOWEVER, while theoretically arguable, my most common PROGRAMMING ERROR is thinking I have a BEGIN...END block simply because it is indented. This usually occurs because I use the further line saving compression method of <br /><br /> FOR i := 1 TO 5 DO BEGIN<br /><br />I am beginning to think that a BEGIN...END block should be just that - a Block of Code. The BEGIN, END, and everthing inside is indented the same. ONLY the entire BLOCK is indented after an IF, FOR, WHILE, etc.<br /><br />I HATE the line wasting and visual distraction off the ELSE in the following:<br /><br />___END<br />___ELSE<br />___BEGIN<br /><br />I hate the waste of indentation in the following:<br /><br />FOR i := 1 TO 7 DO<br />___BEGIN<br />______INC(z)<br />___END<br /><br />I think the MEANINGFUL RULE is that the BEGIN must take up the first line of the BEGIN...END block so that you clearly see that you have such a block. If the BEGIN is tacked on the end of the previously, not-indented line of code, you can quickly assume you have a BEGIN...END merely by the indentation when if fact you forgot the BEGIN.<br /><br />Anyhow, they hate me where I work too!!!!Unknownhttps://www.blogger.com/profile/06037021696741203479noreply@blogger.comtag:blogger.com,1999:blog-6444609270251748954.post-45797178822077964592012-06-18T08:22:29.780-07:002012-06-18T08:22:29.780-07:00Curse your dangling begins...Curse your dangling begins...Bruce McGeehttps://www.blogger.com/profile/09952420043727301654noreply@blogger.comtag:blogger.com,1999:blog-6444609270251748954.post-24173249034532962702012-06-15T06:47:06.020-07:002012-06-15T06:47:06.020-07:00Andreas; I stick to the JEDI style when I am worki...Andreas; I stick to the JEDI style when I am working on JVCL / JCL code, as best as I can, too.<br /><br />When working in another codebase, I stick to that style. You can see how many years of trying to be nice to everybody eventually could turn you into a grumpy old man.<br /><br />I also like to stick to the style that the VCL and the IDE generates, because it makes less "rework" for me. The IDE generates begin and end blocks at the procedure level that line up. Few people change that. But in the area where the user has full control, it seems that users get passionate opinions; Leave out begin and end whenever you can, always use begin and end, but don't need extra lines for them inside procedures, or always start on a newline.<br /><br />Maybe if the Jedi formatter or the Delphi IDE code formatter could reformat just one function, a lot of these holy wars could cease. As it is, I don't trust any formatter to reformat a whole unit, it just makes a mess.<br /><br />WWarrenhttps://www.blogger.com/profile/04053407632823479165noreply@blogger.comtag:blogger.com,1999:blog-6444609270251748954.post-5350249173188332932012-06-15T06:37:13.209-07:002012-06-15T06:37:13.209-07:00This comment has been removed by the author.Warrenhttps://www.blogger.com/profile/04053407632823479165noreply@blogger.comtag:blogger.com,1999:blog-6444609270251748954.post-91619398004647947672012-06-15T06:31:51.385-07:002012-06-15T06:31:51.385-07:00"( arg1,arg2: Integer; arg3: string )" i..."( arg1,arg2: Integer; arg3: string )" is not JEDI style. It must be "(Arg1, Arg2: Integer; Arg3: string)" (space after comma, no space after "(" and no space before ")".<br /><br />What I hate the most is if one single developer can't decide how he wants to format the code. My guess is always that such a developer has a dice next to his keyboard to find out how large the indention should be and where to put the "begin", "else" and "end".<br /><br />Example:<br />.if(.boolexpr)..then...begin<br />.end<br />else // why no indention here?<br />.begin<br />.end;<br /><br /><br />I stick to the JEDI style, not only because I (sometimes) work on the JCL and JVCL code, but also because it is related to the style that is used in the VCL and that the IDE generates.Andreas H.https://www.blogger.com/profile/09493262898327632024noreply@blogger.com