Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

Tabs or Spaces Expand / Collapse
Author
Message
Posted Saturday, March 17, 2012 7:22 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 8:25 PM
Points: 31,279, Visits: 15,740
Comments posted to this topic are about the item Tabs or Spaces






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1268704
Posted Sunday, March 18, 2012 11:37 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, November 19, 2014 12:06 PM
Points: 887, Visits: 2,453
I propose the following amendment to "... only programming project with no disagreement whatsoever on code formatting is the one you work on alone", to wit:

"... only programming project with no disagreement whatsoever on code formatting is the one you work on alone, or when everyone viewing the code runs it through a code beautifier first".

My answer to tabs vs. spaces, case convention, and pre vs post commas is always to let a computer do tedious, menial, purely rules based work - use a SQL beautifier/formatter. If someone else doesn't like your settings, they can use _their_ settings. None of that matters to the SQL parsing engine, so why should it matter to us?

There's a few out there, of which SQLInform is a reasonable one, though it doesn't have as many options for list indentation as I'd like. It does handle at least some of the tabs vs. spaces conversions, to however many spaces per tab you prefer!
Post #1268746
Posted Sunday, March 18, 2012 10:30 PM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Friday, November 21, 2014 6:49 AM
Points: 1,443, Visits: 1,855
Perhaps the major reason I hate tabs in code is that tabs are not interpreted in the same way on all systems - some may have 4 spaces, others may have 7. This leads to a perfectly aligned and readable code on one machine, but mis-aligned code on another machine.

Another reason why I am against tabs is that result in the cursor jumping all over the place when scrolling up or down using the keyboard to find where an "END" exists for a particular "IF".

I always insist that my team has the "replace tabs with spaces" switch in SSMS options checked and also run code through the "beautifer" option of "Untabify selection".

In my humble opinion, there should be a consistent set of coding aesthetic standards that should be enforced by default (and result in warnings) by Visual Studio and associated tools.


Thanks & Regards,
Nakul Vachhrajani.
http://nakulvachhrajani.com
Be courteous. Drive responsibly.

Follow me on
Twitter: @sqltwins
Google Plus: +Nakul
Post #1268788
Posted Sunday, March 18, 2012 10:43 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 6:31 PM
Points: 13,207, Visits: 12,688
I would tend to lean on the side of preferring tabs to spaces. I have worked in some environments where tabs would retain spaces like you mention but everybody had their own personal preference as to how many spaces represented a tab. The sql people typically used 4 spaces and the Delphi people typically used 8 spaces. It made all the stored procs so horribly formatted that we actually created a function (as a joke) to assign a random number of spaces to indent each line.

I can't imagine actually having an argument about it because I really don't think there is the one right way to go here. For me there plenty of other things to have arguments about than the differences between tabs and spaces.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1268790
Posted Sunday, March 18, 2012 11:53 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 11:33 PM
Points: 130, Visits: 187
I will vote for tabs. Why? Just because I am lazy and using the arrow key to jump 4 spaces makes me smile. Our standards include the setup of the development environment. So tabs never cause ugly displays, and so I like it. I will retire in this company, so I do not have to worry about maintaining Steve's code someday.

5ilverFox
Namakwa Sands
South Africa
Post #1268796
Posted Monday, March 19, 2012 2:17 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, October 22, 2014 7:02 PM
Points: 2,157, Visits: 879
My Vote is for Spaces.

As previously mentioned there is no consistency in the interpretation of Tabs. I've seen 2, 4 & 8 Spaces.

Spaces are portable whereas Tabs are IDE specific.

I personally go for 2 Spaces mainly because I prefer to see all of my Code on one Screen without having to scroll left & right all of the time.

David
Post #1268830
Posted Monday, March 19, 2012 2:25 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, September 22, 2014 1:20 AM
Points: 1,404, Visits: 1,315
I vote for tabs. They can be extremely rapidly shown as 3, 4, 7... spaces by configuration and they can be converted to spaces if needed.
As I'm minority, I have my Visual Studio set to spaces.




See, understand, learn, try, use efficient
© Dr.Plch
Post #1268834
Posted Monday, March 19, 2012 2:32 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 3:49 AM
Points: 1,622, Visits: 5,695
There's no inconsistency in formatting using tabs provided you always use them--whether the code gets indented 4 or 8 spaces with a tab is largely irrelevant to its readability. Having said that, I prefer to use spaces simply because I can use fewer of them--I think a 2-space indent is ample, and if you use more than that (or use tabs) then you can end up having to scroll right to read the code in some cases!

Of course, these days it's almost a moot point because pretty much any competent code editor will have the capability of automatically indenting lines to suit your preferences.
Post #1268840
Posted Monday, March 19, 2012 2:33 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, November 13, 2014 7:58 AM
Points: 849, Visits: 336
I prefer spaces simply for the main reason that T-SQL code is easier portable and readable between SSMS and BIDS.
BIDS by default uses 8 spaces for a tab where SSMS is configurable. SSMS has a big screen for code review, BIDS by default has a tiny window.
Tabs in BIDS can make the code disappear right out of the window. This then means extra efforts to enlarge the window, after review (and fix) back to default size and just simply more clicks than I want to count. All of this can be achieved with even more key strokes.

My main pet pieve is simply lazy developers who just don't care to follow one style and just mix and match then complain about the coding standards of others.
Post #1268841
Posted Monday, March 19, 2012 3:50 AM


Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, November 13, 2014 10:43 PM
Points: 22, Visits: 184
I vote for tabs - less key strokes
Post #1268870
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse