We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27376
    • 576 Posts
    Quote from: OpenGeek at Jan 24, 2008, 09:16 PM

    And no, this isn’t Python, but the same issues apply regarding using various editors, some that are simply inept at dealing with the problem properly.

    ...

    Regarding the 4 bytes vs 1 byte argument, I do agree the space savings could be important for objects being delivered to the browser, but I’m not convinced that this point trumps the other issues. But I’m certainly not going to block any dialog on the subject, so feel free to convince me otherwise, or override my veto...
    wink
    Because I’m a huge supporter of tabs (and because Jason said I can do so), I want to open this topic up for some debate. My most curious question is: who on the team is using an editor that doesn’t fully support tab indenting?

    Perhaps to get a better idea we could compile a list and tally all of the current team’s preferred editor. I would be surprised if people on the team are using editors that don’t support tabs; but maybe I should bite my tongue because I really don’t know all the coders on the team as well as I should...

    Personally, I will follow whatever standard is set in place for this project. But here’s my proposal regarding this: Use tabs for indentation only and use spaces only when aligning text/comments that span multiple lines.

    Here’s an example of my proposal in action:
    <?php
    /**
     * Used only to demonstrate when to use spaces as opposed to
     * tabs when writing/indenting code.
     * 
     * "___>" = tab character
     * "...." = 4 space characters
     */
    function example_function() {
    ___>if (true)
    ___>......return true;..// A comment that will span
    ___>else..return false;.// multiple lines
    }
    Coding in this manner will give each programmer their own control over how many spaces a tab should be interpreted as and also ensures that each programmer will see the code aligned the way it should be.

    Give it a try in your favorite editor (replacing it with the appropriate tabs/spaces). I’ve been indenting in this manner for two years, across 3 different editors, and my code looks the same in each one.

    Edit: As for compiling and tallying a list of editors our programmers use, I thought about starting a new list on listze. However, since any registered user is able to vote and add list items, it might not be the best option. I’m open to other ideas.
      • 3749
      • 24,544 Posts
      My editor (PhpEd) will go either way on this and I don’t feel strongly one way or the other, but I’d prefer to go all tabs or all spaces.

      The main argument for tabs is to save bytes, but that argument goes out the window if you use spaces everywhere to line up text/comments.

      Bob
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 20289
        • 958 Posts
        Quote from: BobRay at Jan 27, 2008, 05:49 PM

        The main argument for tabs is to save bytes, but that argument goes out the window if you use spaces everywhere to line up text/comments.

        +1 Thumbs up.
          [img]http://i10.tinypic.com/52c4eir.gif[/img][/td]
          [td][Wiki] [Persian support forum]
          [SVN] [RTL SVN Branch] [bugs] [FishEye+Crucible] [Learn MODx!] | [My Google Code]
          [font=tahoma][برای دسترسی به راهنمای فارسی به [url=http://www.modxcms.ir]
          • 23491 ☆ A M B ☆
          • 1,056 Posts
          Quote from: sirlancelot at Jan 25, 2008, 04:45 AM

          Here’s an example of my proposal in action:
          <?php
          /**
           * Used only to demonstrate when to use spaces as opposed to
           * tabs when writing/indenting code.
           * 
           * "___>" = tab character
           * "...." = 4 space characters
           */
          function example_function() {
          ___>if (true)
          ___>......return true;..// A comment that will span
          ___>else..return false;.// multiple lines
          }


          Coding in this manner will give each programmer their own control over how many spaces a tab should be interpreted as and also ensures that each programmer will see the code aligned the way it should be.

          I’m more of a tabber than a spacer smiley Although, the EditArea plugin I use (see signature) does incorporate a Tab vs. Space option. Most of my internal MODx content, snippets, etc are indented w/ 4 spaces.

          Overall code legibility can make a big difference in one’s ability to quickly understand something that is new to them, code comments definitely factor in here as well. I think the initiative is well-founded, as it is setting a precedent for 0.9.7+.

          Personally, I have practiced your outlined technique myself and have found that aligning the comments, etc can sometimes be tedious. For me, it usually depends on how fast I am developing/bug testing/etc. Since my code may go through a few stages before reaching its final form, I feel less efficient when I am constantly aligning/re-aligning associated comments, etc. On the flip side, if I choose not to do so along the way, the task still remains and sometimes I am less motivated to "clean up" the code.

          I have no problem agreeing to standardizing internal coding practices in regards to Tabs/Spaces. I have been using EmEditor for a few years now, and I believe it properly supports tab indentation.
            Mike Reid - www.pixelchutes.com
            MODx Ambassador / Contributor
            [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
            ________________________________
            Where every pixel matters.
            • 28215
            • 4,149 Posts
            http://docs.modxcms.com/modext/

            See "Editor Settings and Spacing" under "MODx Coding Standards".

            More to come.
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
              • 23491 ☆ A M B ☆
              • 1,056 Posts
              Quote from: splittingred at Jan 29, 2008, 09:49 PM

              http://docs.modxcms.com/modext/

              See "Editor Settings and Spacing" under "MODx Coding Standards".

              More to come.

              Editor settings updated. Welcome 4-space plus auto-indent! Thx EmEditor
                Mike Reid - www.pixelchutes.com
                MODx Ambassador / Contributor
                [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                ________________________________
                Where every pixel matters.
                • 27376
                • 576 Posts
                I have no problem adhering to standards, I was just putting in my two cents to get a feel for what programs the team is using. I still consider myself the new kid on the block when it comes to the MODx team and I’m certainly not in any position to tell anyone what to do wink

                All of the scripts I create for MODx will have whitespace formatted the way you see in the first post, however, when programming in the core, I will format according to our standard.