D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Java, VIM, tabs, spaces and indents

 

Tom Potts wrote:
> On Saturday 03 February 2007 21:46, Simon Williams wrote:
>> Benjamin A'Lee wrote:
>>> On Sat, Feb 03, 2007 at 08:27:19PM +0000, Simon Williams wrote:
>>>> I'm now doing java in my computer science course. Much to my irratation,
>>>> I have discovered that java is poorly designed language which makes all
>>>> code indented by an extra level because of the class definitions.
> The Java compiler does not insist on any indentations - thats someones idea of 
> 'proper style' which is frankly useless if you have to write anything of any 
> complexity. 

Could you elaborate on that? I'd have thought that a sensible coding 
style would be more important when coding something complex.

> Coding 'Styles' are meant to make the code more readable but if 
> the text is seven feet to the right then theres something wrong - try to 
> refactor but it can be the style thats 'at fault'.

To quote Torvalds from the linux kernel coding standards:
"if you need more than 3 levels of indentation, you're screwed anyway, 
and should fix your program."

>>> Why not just not bother indenting after the class definition?
>> That's probably what I'll do if I ever use java for anything else.
>> Unfortunately the style rules for this are no hard tabs, indents must be
>> consistent and 4 spaces or less.
>>
>> For the purposes of arguing my case:
>> Am I right in thinking that the class definition will usually (or even
>> always) span the whole file, even in very large programs?
> you can have many classes in a file if you want
> I'd suggest using a different editor (emacs?)

I wouldn't touch emacs with a barge pole, but I think we should avoid 
flaming on that one.

> or even IDE like netbeans - well cool!

I don't like IDE's. If I found I needed one I might look at the 
possibility, but at the moment I'm much happier with command line tools.

> Vims good  if you have to use a simple monitor and its good to know how 
> to use it 

If you're only dealing with text then you don't need a gui. I also 
really don't like all this clicking that can be done better with key 
commands.

 > but its a bit hair shirt for a college course!

Why?

> Whatever it is tho find an editor your happy with and then use sed or 
> something to process the files to whatever standard your tutor/college 
> requires.

Indent is useful (once it is given some sane options).

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html