• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Refactoring: long statements vs. line space 80

 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am using refactoring extensively and think it's great.

but following problem:

if i use for instance Rename Method, Extract Method, Replace Temp with Query or similar it has got the effect, that statements get quite lengthy (>80 chars). never the less the code gets much better readable/understandable, which is one of the aims of refactoring.
on the other hand there is a coding standard where the line should not exceed 80 chars. if i follow this rule the statements gets split over two lines, which makes reading very difficult thus understanding takes longer.

so in my view these 80 chars is just too little to make good naming, replacing/extracting practicable. maybe it made sense in former times, but today we got big enough screens to accomplish that. and anyway i am not developing on a slow resolution terminal...

what do you think or how do you handle above problem?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by manuel aldana:
if i use for instance Rename Method, Extract Method, Replace Temp with Query or similar it has got the effect, that statements get quite lengthy (>80 chars).



How do the statements get longer by using those refactorings? Can you give an example of such a long line?



so in my view these 80 chars is just too little to make good naming, replacing/extracting practicable. maybe it made sense in former times, but today we got big enough screens to accomplish that. and anyway i am not developing on a slow resolution terminal...

what do you think or how do you handle above problem?



At work, our coding standard sets a limit of 100 (or 120? I don't remember exactly...) characters per line. I think that is quite a reasonable limit.
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think its more about printouts than screen sizes.

I don't personally have a limit. I let it go until it gets annoying.

In Eclipse you can adjust how it formats code and what it will wrap and not wrap and how and how many lines, etc..
 
manuel aldana
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


is refactored to:



the longer line basically comes from the fact that i choose self explaining method names (which often get long) when using Extracting Method and further more try to avoid unneccessary temps.

i think i will adjust my IDE to 100 or 110 chars, that is definetely enough for my coding style.
[ August 17, 2006: Message edited by: manuel aldana ]
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by manuel aldana:
the longer line basically comes from the fact that i choose self explaining method names (which often get long) when using Extracting Method and further more try to avoid unneccessary temps.



I see.

For what it's worth, I typically use "extract local variable" quite a lot to break a too long line up into several smaller lines.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:
For what it's worth, I typically use "extract local variable" quite a lot to break a too long line up into several smaller lines.


Me too. I don't find them "unneccessary." They make the code easier to read and help on the occasions where I need to use the debugger.
 
reply
    Bookmark Topic Watch Topic
  • New Topic