LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-26-2010, 07:02 AM   #16
fpsasm
LQ Newbie
 
Registered: Feb 2010
Location: UK, Leeds
Distribution: PCLinuxOS, Fedora Core, SuSE,ubuntu
Posts: 20

Rep: Reputation: 1

Quote:
Originally Posted by MTK358 View Post
I agree completely (except I don't use Hungarian Notaton, not sure whether it really makes sense for me).


[ off topic kinda ]
The point of hungarian notiation, is so that you can instantly see what kind of variable it is, just by its name..

So, you normaly do:
[type of variable][name or discription of variable]

so you have a variable called result of a type float, you do: flRes , for example, (where 'fl' means float, and 'Res' means result, note the camel case :P)

it helps when you have like 123012401989012419823091 variables ^^

its kind of a old technique.. but meh, I like it :P Wikipedia has a good page.
 
Old 02-26-2010, 08:39 AM   #17
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Quote:
Originally Posted by fpsasm
it helps when you have like 123012401989012419823091 variables ^^
Seems like if you have that many variables, naming the variables right would be the least of your concerns...

I looked at the page and noticed that I do sometimes use "Apps Hungarian", though.

Last edited by MTK358; 02-26-2010 at 08:41 AM.
 
Old 02-26-2010, 01:02 PM   #18
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 547

Rep: Reputation: 115Reputation: 115
I use tabs but with tab emulation in the editor to bring it down to two spaces!
 
Old 02-26-2010, 04:14 PM   #19
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,245
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
Personally I think using spaces as indents makes programming slower and inconsistent or style without speed at least. Using spaces, you can't even use <TAB> or <SHIFT-TAB> on a selected block to increase or decrease levels. There's also a higher tendency for misalignment and extra trailing spaces.
 
Old 02-26-2010, 06:57 PM   #20
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,376

Rep: Reputation: 147Reputation: 147
Quote:
Originally Posted by konsolebox View Post
Personally I think using spaces as indents makes programming slower and inconsistent or style without speed at least. Using spaces, you can't even use <TAB> or <SHIFT-TAB> on a selected block to increase or decrease levels. There's also a higher tendency for misalignment and extra trailing spaces.
I don't know which editor you use but I think all the editors that I use permit me to do what you have described. That is I select a block a code do a block indent (usually using a Tab key to indent and Shift-Tab combination to unindent) and the block of code will be modified and the tabs converted to spaces as I prefer.

I don't see and inconsistency in my code presentation nor any noticeable slow down in my ability to present the code the way I want it to be.
 
Old 02-28-2010, 03:50 AM   #21
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,245
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by graemef View Post
I don't know which editor you use but I think all the editors that I use permit me to do what you have described. That is I select a block a code do a block indent (usually using a Tab key to indent and Shift-Tab combination to unindent) and the block of code will be modified and the tabs converted to spaces as I prefer.

I don't see and inconsistency in my code presentation nor any noticeable slow down in my ability to present the code the way I want it to be.
Is that also applicable with VIM?

Also I'm thinking about the level of probabilities. It may not appear inconsistent to you and your code (it's your option and so in other programs just like drupal's and i respect it so it's ok) but to me e.g. when I do C++, it's *likely* that I'll get inconsistencies with the code. It won't be easy to explain as there are many situtations with programming C++ that if I use spaces as indents will just cause inconsistencies. Again that's just to me. And it's not just about the presentation. Overall that is.
 
Old 02-28-2010, 06:23 AM   #22
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by sundialsvcs View Post
The only language where indentation actually matters is Python.
And Occam too, if I remember rightly...

Oh, and the old FORTRAN on punched cards :-)
 
Old 02-28-2010, 06:36 AM   #23
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 59
Quote:
Originally Posted by neonsignal View Post
Quote:
Originally Posted by sundialsvcs
The only language where indentation actually matters is Python.
And Occam too, if I remember rightly...

Oh, and the old FORTRAN on punched cards :-)
And Haskell. Probably some other languages too, that I don't know or have never heard of.

If I'm working on something alone (which is usually), I follow the community norms for the language (e.g. 2 space tabs for Ruby, but 4 space tabs for Perl). If you're on a team, you have to agree as a group.

Last edited by Telemachos; 02-28-2010 at 06:38 AM.
 
Old 02-28-2010, 08:00 AM   #24
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 110Reputation: 110
Quote:
Is that also applicable with VIM?
set expandtab, <<, and >>

I hate tabs, they make code formatting far too complicated. Tabbed code isn't appropriate for copying into forums and is annoying when using diff, grep, cat, or less. Tabs originally existed to make tables, not indent code.
 
Old 02-28-2010, 08:10 AM   #25
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,376

Rep: Reputation: 147Reputation: 147
Quote:
Originally Posted by konsolebox View Post
Is that also applicable with VIM?
I don't know since I don't use vim. However I'm sure that it can be achieved.

A quick google gave me this which looks promising.

Quote:
set expandtab
set shiftwidth=2
set softtabstop=2
I use C++ quite a bit and I'm having difficulty thinking of a situation where using spaces would cause inconsistencies in the formatting. I don't think that it is a language issue, rather how you configure the editor to help you.
 
  


Reply

Tags
programming, spacing, style


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basename and spaces: Directory has a space in its name Cyberman Programming 1 03-22-2009 05:54 AM
What is the unix command to trim multiple spaces into single space? manohare Linux - General 4 03-02-2009 07:25 AM
Replacing Tabs (^T) with spaces.... visitnag Linux - Newbie 3 05-04-2008 03:30 AM
tabs to spaces in emacs, not working in tcl mode ratm1286 Linux - Software 3 05-08-2005 05:15 PM
emacs - convert auto indent tabs to spaces? BrianK Linux - General 1 04-15-2004 10:14 PM


All times are GMT -5. The time now is 01:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration