<![CDATA[ 0.9.7 Coding standards (and the obligatory tab vs. spaces war) - My Forums]]> https://forums.modx.com/thread/?thread=32119 <![CDATA[Re: 0.9.7 Coding standards (and the obligatory tab vs. spaces war)]]> https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173973

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.]]>
sirlancelot Jan 31, 2008, 01:14 PM https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173973
<![CDATA[Re: 0.9.7 Coding standards (and the obligatory tab vs. spaces war)]]> https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173972 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]]>
pixelchutes Jan 29, 2008, 04:16 PM https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173972
<![CDATA[Re: 0.9.7 Coding standards (and the obligatory tab vs. spaces war)]]> https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173971 http://docs.modxcms.com/modext/

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

More to come.]]>
splittingred Jan 29, 2008, 03:49 PM https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173971
<![CDATA[Re: 0.9.7 Coding standards (and the obligatory tab vs. spaces war)]]> https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173970 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.]]>
pixelchutes Jan 29, 2008, 03:11 PM https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173970
<![CDATA[Re: 0.9.7 Coding standards (and the obligatory tab vs. spaces war)]]> https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173969 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.]]>
motsmart Jan 27, 2008, 10:24 PM https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173969
<![CDATA[Re: 0.9.7 Coding standards (and the obligatory tab vs. spaces war)]]> https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173968
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
]]>
BobRay Jan 27, 2008, 11:49 AM https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173968
<![CDATA[0.9.7 Coding standards (and the obligatory tab vs. spaces war)]]> https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173967 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.]]>
sirlancelot Jan 24, 2008, 10:45 PM https://forums.modx.com/thread/32119/0-9-7-coding-standards-and-the-obligatory-tab-vs-spaces-war#dis-post-173967