I didn't even notice that this is what they were referring to. I always match brackets, and I even put brackets on statements that only execute one line of code. It may take more space, but it's more organized, IMO.AKA Panama Jack wrote:This is by far the BEST way to enter functions because it is much easier to visually match beginning and ending brackets.
Coding standards... and me.
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
astions wrote:Tabs are the work of the Devil. If I was god I would abolish them into the depths of nothingness. They are useless placeholders destined to be replaced with spaces.
The files are different when you compare the whitespace. But because (besides Python) most languages are whitespace independent it does not matter to PHP.astions wrote:But the files are different. They should show as different.
If anything, I would think the infinitesimal time it takes to parse over all those extra space characters rather than the far fewer tabs would make a man of your passionate opinions pro-tab!
(#10850)
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
The counter argument I have heard to this is that because modern editors will show bracket errors that never using one true brace is more consistent shows more program lines per page -- which is an essential goal of that style.AKA Panama Jack wrote:This is by far the BEST way to enter functions because it is much easier to visually match beginning and ending brackets.Code: Select all
function bar($more) { //do that }
FYI - that opening brace style was because in C you declared parameters between the function declaration line and the code block, so the opening code brace lined up with those declarations. Languages like PHP put the parameter declaration in the function declaration line so the one true brace is no longer needed.
(#10850)
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Yup, that's the reason to use spaces. It is often a good practice on teams that use different editors, as well as large public projects. However if the team can configure their editors to translate, or have the CVS to it for them, then it can become a non-issue. I have worked on teams where each programmer checked out code with their own preference. Releases were pretty-printed to some agreed upon target.astions wrote:I became annoyed with tabs when my code would get misaligned from one editor to another. That never happens with spaces, so my code is still pretty
(#10850)
That sounds like a pretty cool way to do it. I find myself going through others code and indenting it properly. I don't know if it makes the other guys mad or not but they never say anything about it lol.arborint wrote:I have worked on teams where each programmer checked out code with their own preference. Releases were pretty-printed to some agreed upon target.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I should have to clean up all my code. What I do is probably anathema to you -- I don't care much if the indenting is a little off so I just leave it however it is ...astions wrote:That sounds like a pretty cool way to do it. I find myself going through others code and indenting it properly. I don't know if it makes the other guys mad or not but they never say anything about it lol.
(#10850)
That would be the Zend standard way. Always brackets. Always. =] I like it that way. I like the function brackets.. but not so much the if ()'s.superdezign wrote:I didn't even notice that this is what they were referring to. I always match brackets, and I even put brackets on statements that only execute one line of code. It may take more space, but it's more organized, IMO.AKA Panama Jack wrote:This is by far the BEST way to enter functions because it is much easier to visually match beginning and ending brackets.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
That is an editor problem and not a coding problem. I have tried many different editors before sticking with UEStudio and every one of them would cut and paste tabs perfectly if you disabled the "TABS as SPACES" feature if the editor has it.astions wrote:I became annoyed with tabs when my code would get misaligned from one editor to another. That never happens with spaces, so my code is still pretty
Personally, I found far more problems with misaligned cut and paste code when programmers used SPACES instead of TABS because it seems like every programmer has a different definition of how many spaces it takes to make a tab. If you use TABS then they will ALWAYS be the right distance when you cut and paste between applications.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
I have heard that too and find it an annoying argument.arborint wrote:The counter argument I have heard to this is that because modern editors will show bracket errors that never using one true brace is more consistent shows more program lines per page -- which is an essential goal of that style.AKA Panama Jack wrote:This is by far the BEST way to enter functions because it is much easier to visually match beginning and ending brackets.Code: Select all
function bar($more) { //do that }
Most modern editors will do automatic bracket matching. I use UEStudio and it does that as well but I like being able to LOOK at program code and tell at a glance where bracketed code blocks are instead of moving the cursor to each bracket to see the corresponding bracket highlighted. The latter is time consuming and less efficient.
@arborint: The main reason why I go through and indent the code is because I can process the code and know where I am in the flow without having to actually read the code. This makes it much faster and easier for me to zero in on the part I want to modify. When it's not indented I have to read the code instead of just the if/while/foreach statements. Also, it's amazing how many undiscovered bugs I have found by doing this.
@aka: Are you a windows fan? I would venture to guess that most Linux guys probably prefer spaces, while most windows guys prefer tabs.
@aka: Are you a windows fan? I would venture to guess that most Linux guys probably prefer spaces, while most windows guys prefer tabs.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
I prefer Linux for servers as it is better suited for that task.
I don't care for Windows but I use it because I have to use it if I want to use certain applications and games. Yes, games also play as bit a part as applications. Linux is getting there but way too slowly for my tastes. Until entertainment companies start including Linux versions by default in all of their releases I doubt that I will be switching anytime soon.
I don't care for Windows but I use it because I have to use it if I want to use certain applications and games. Yes, games also play as bit a part as applications. Linux is getting there but way too slowly for my tastes. Until entertainment companies start including Linux versions by default in all of their releases I doubt that I will be switching anytime soon.
- The Phoenix
- Forum Contributor
- Posts: 294
- Joined: Fri Oct 06, 2006 8:12 pm
To which I say, welcome to the world of 20"+ monitors, dual monitors, zooming text, and IDE's that do code folding. I'm not a fan of modern IDE's, but the whole "I can see more on one page" line seems more and more laughable as monitors get larger than windshields..arborint wrote:The counter argument I have heard to this is that because modern editors will show bracket errors that never using one true brace is more consistent shows more program lines per page -- which is an essential goal of that style.
A rephrase could be that there are some diff programs that offer the ability to ignore whitespace differences. But by default almost every one of the unix standard diff (for the last twenty YEARS mind you) has indeed seen tabs as different than spaces.AKA Panama Jack wrote: Any Diff programm worth it's salt will basically ignore leading spaces and tabs that are outside quotes when comparing file code. If it doesn't then that DIFF program has a really bad problem. I have one called Free Diff that only compares actual code differences which is what a Diff program should do.
Because they are.
But yes, you can get an editor that converts tabs to spaces. And yes, you can get a diff program that ignores tabs v. spaces, and you can also even use a program to prettify the formatting before committing. But in the end, all of those give you workarounds to the main problem - inconsistencies between programmers.
Which is why we have coding standards.AKA Panama Jack wrote:it seems like every programmer has a different definition of how many spaces it takes to make a tab
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Couldn't be more wrong on that because you will find different people claiming coding standards that use spaces instead of tabs have different idea as to what is the proper number of spaces to use in place of tabs.The Phoenix wrote:Which is why we have coding standards.AKA Panama Jack wrote:it seems like every programmer has a different definition of how many spaces it takes to make a tabBy saying "no tabs at all", that issue is entirely eliminated.
You see tabs were created for a REASON way back in the old typewriter days and refined with computers. Tabs have a built in STANDARD for width so if you use a tab in one editor it will show properly in another program unlike spaces. Just about every major or decent editor that offers the ability to use tabs instead of spaces allows the number of spaces per tab to be set by the user. And you will find that not all editors have the same default number of spaces to represent a tab.
If any programmer wants to have display consistency they would never use spaces but stick with tabs as tabs because the display will always be the same no matter what editor they use. Even Linux editors support tabs as tabs. You would probably have to really dig to find a modern editor, even on Linux, that doesn't display tabs properly as tabs.
Last edited by AKA Panama Jack on Sat Aug 11, 2007 1:05 am, edited 1 time in total.