Slashdot Mirror


Eclipse Finally Gets Code Folding

binarysearch writes "Code folding is finally in the Eclipse project! After more than two years open, Eclipse's Bug 9355 has finally been marked FIXED. Code Folding was the most-voted for bug in Eclipse, with support for J2SE 1.5 features in a close second. Check out the I20040504 Integration build for folding in the Compilation Unit Editor (Class File Editor support is in HEAD). For those who dislike the implementation, it is requested that you create a new bug, rather than reopening 9355."

90 comments

  1. Code folding is: by Elwood+P+Dowd · · Score: 4, Informative
    Code folding is where you can collapse a block of code between a set of squirrely braces so it reads"
    { ... }
    or
    // ...
    or
    /* ... */
    Or whatever. Yes, this is like VS.NET and a million other IDEs. I use it all the time, but it never would have occured to me that it was a big deal. I figgered y'all FS/OSS types would use incremental search and brace matching to go anywhere in your code, rather than the scrolly-wheel. Isn't that what "real" programmers would do?
    --

    There are no trails. There are no trees out here.
    1. Re:Code folding is: by Yokaze · · Score: 4, Interesting

      > Isn't that what "real" programmers would do?

      Or what about keeping the code blocks small and concise? See Linux kernel coding style Chapter 4.
      If you have to scroll some pages to find the corresponding closing tag, something has gone wrong.

      But I've to admit, that I use code folding myself, which shows, I'm not a real programmer. But I also prefer Emacs to vi, which only confirms the fact I'm a quiche eater.

      --
      "Between strong and weak, between rich and poor [...], it is freedom which oppresses and the law which sets free"
    2. Re:Code folding is: by jpu8086 · · Score: 2, Troll

      Not withstanding your trivial explanation, what the fuck are you trying to do -- little troll?

      No, a million other IDEs don't have it. I only know of two: VS.NET and IDEA J.

      And no, Eclipse is an OSS project. It is not limited to usage by FS/OSS programmers.

      And no, FS/OSS programmers demand high-standard devlopement tools too which equates to great ease of use. Why do you think we have simple, and easy to use build systems (make) and revision systems (subversion, cvs)? We also like GUI builders (Glade, QT Designer) , when we have to produce GUI code.

      Now, go home and troll to your momma.

      --
      now supporting:
      cmdrTaco for president '04
      michael for oval office intern summer '05
    3. Re:Code folding is: by abrotman · · Score: 3, Interesting

      iirc .. VS.NET, Dreamweaver, Homesite,bluefish,anjuta,eclipse(now), probaby kate, and god knows how many more have this .. its a pretty common feature ive seen in most "major" code editors(dunno about vi(use %) or emacs).

    4. Re:Code folding is: by jpu8086 · · Score: 2, Informative

      Dreamweaver, Homewise, Bluefish: you do Java coding in it? Wow.

      Anjuta doesn't have it. I'm using it right now.
      Kate, I doubt it. It's a text editor.
      Vi doesn't.
      Emacs, I dont know.

      --
      now supporting:
      cmdrTaco for president '04
      michael for oval office intern summer '05
    5. Re:Code folding is: by jpu8086 · · Score: 2, Interesting

      never mind. Anjuta does.
      Ooops. I just upgraded my old ass version.

      Forgive me, senor.

      --
      now supporting:
      cmdrTaco for president '04
      michael for oval office intern summer '05
    6. Re:Code folding is: by Elwood+P+Dowd · · Score: 3, Insightful

      I'm sorry. What on Earth lead you to believe that I have some kind of a problem with FS/OSS development methodologies? I feel that, for good programmers, brace matching and incremental search provide all the "ease of use" that's necessary for living without code folding.

      What sort of a response would I have been trolling for?

      --

      There are no trails. There are no trees out here.
    7. Re:Code folding is: by Anonymous Coward · · Score: 0

      So you prove your point by naming 2 text editors barely anybody has heard of (and even fewer actually use), and 2 more that are basically extinct?

      I'd debate your point if you had one, butt breath.

    8. Re:Code folding is: by dedazo · · Score: 3, Insightful

      vim does support folding, though it's a little quirky to get just right. Most editors based on Scintilla (which is very popular with the Python crowd) do as well.

      --
      Web2.0: I love when people Flickr my cuil and digg my boingboing until my google is reddit and I start to yahoo
    9. Re:Code folding is: by BRSloth · · Score: 3, Informative

      Vi (as 6.2.x, at least) have code folding:

      Add in your .vimrc:
      set foldmethod = marker

      And, on your code, do comments like this: /* add function {{{ */
      void stuff(void)
      {
      weird_stuff();
      } /* }}} */

      use 'zc' to close the fold and 'zo' to open it. More info? :help fold

    10. Re:Code folding is: by sporty · · Score: 1

      Real programmers use the tools they like. I like code folding because it forces me to see everything that's going on in the class, when I'm say, modifying two functions.

      --

      -
      ping -f 255.255.255.255 # if only

    11. Re:Code folding is: by hankaholic · · Score: 1

      Vim offers code folding. There are even Windows and KDE-enabled versions.

      I'd be really surprised if EMACS didn't offer something similar.

      --
      Somebody get that guy an ambulance!
    12. Re:Code folding is: by mattgreen · · Score: 1

      Real programmers don't believe they have to do arbitrary things because "Elwood P Dowd" said so.

    13. Re:Code folding is: by aled · · Score: 1

      jEdit, Netbeans...

      --

      "I think this line is mostly filler"
    14. Re:Code folding is: by FAT_VIRGIN · · Score: 3, Informative

      That's VIM, not vi.

    15. Re:Code folding is: by Elwood+P+Dowd · · Score: 1

      Hey, whether I'm a real programmer or not is easily confirmed by my coworkers. They say I learned VB 6 in record time .

      P.S. I *asked* whether that was something "real" programmers would do. I guarantee you, I'm not a "real" programmer.

      I think I've only ever met one or two. And they didn't write SQL queries. For cash. On the street. Eating government cheese.

      --

      There are no trails. There are no trees out here.
    16. Re:Code folding is: by Anonymous Coward · · Score: 0

      I first saw code folding about 20 years ago, but it was implemented on a terminal.

    17. Re:Code folding is: by Anonymous Coward · · Score: 1, Informative

      Code folding was implemented in Xedit on VM/CMS at least twenty years ago, and probably earlier than that. Nice to see that Eclipse has finally caught up. It would be nicer if they organized their IDE so that I could use the editor I already have and know instead of having to use their inferior editor and wait for it to catch up.

    18. Re:Code folding is: by jrumney · · Score: 1
      I'd be really surprised if EMACS didn't offer something similar.

      I'd be really surprised if the idea didn't come from Emacs in the first place. outline-mode has existed in Emacs since the '80s, and before it was made to play nicely with other programming modes by default (it used to take a lot of configuration for anything other than bullet-point text like the Emacs NEWS file), someone wrote a folding-mode (apparently in 1992) specifically for curly-brace languages (C/C++ etc).

    19. Re:Code folding is: by bloo9298 · · Score: 1

      I believe there was an Occam editor with folding support before Jamie Lokier wrote the Emacs folding mode.

    20. Re:Code folding is: by Zebra_X · · Score: 1

      If you have to scroll some pages to find the corresponding closing tag, something has gone wrong.

      Perhaps, but it's just as annoying tracing your way through a bunch of method/function calls.

    21. Re:Code folding is: by pyrrhonist · · Score: 1
      Perhaps, but it's just as annoying tracing your way through a bunch of method/function calls.

      Same rule applies. If you have to trace through a bunch of methods, it's time to refactor, because something has gone wrong.

      --
      Show me on the doll where his noodly appendage touched you.
    22. Re:Code folding is: by BRSloth · · Score: 1

      You are right. I'm using vim for so long that I always forget that there is a vi around... :)

    23. Re:Code folding is: by MentosPimp · · Score: 1

      Im pretty sure that you CAN use an external editor with eclipse. Unless of course that functionality is broken?

    24. Re:Code folding is: by njcoder · · Score: 1

      I've been using it in netbeans since one of the early 3.6 betas I downloaded. It's in the 3.6 version that was recently released.

    25. Re:Code folding is: by revscat · · Score: 1

      I tend to use vim when editing either HTML, XML, or other markup languages. (And, in fact, SQL stored procedures, because we use MS SQL Server at my work and it's native editor is t3h suck.) I use brace matching, incremental search, and vim's code folding functionality. Especially when working with large HTML or XML files, folding up large sections of code makes it much less... stressful to see what's going on. Personal preferences differ, I'm sure. I like it.

  2. code folding? by jpu8086 · · Score: 5, Interesting

    this is a misnomer. i was lost for a while. i was under the assumption that code folding is akin to code wrapping (which eclipse has had since day 1)

    i would rather term it code collapse...and which is what they call it in the main bug report. however, lots of people call it folding in the followup comments.

    i guess i better get used to it being called code folding too.

    so, i am happy that i can collapse 100s of lines of code into just the relevant 10-15 lines of code easily. however, i think this can create a problem of introducing silly error pass through (because you dont have the whole perspective on things). i think they have a feature to collapse all code that doesnt involve a variable "x". Anyone tested this yet?

    --
    now supporting:
    cmdrTaco for president '04
    michael for oval office intern summer '05
    1. Re:code folding? by Anonymous Coward · · Score: 0

      i guess i better get used to it being called code folding too.

      Um, yeah, maybe you should, because we've been using the term for decades. Welcome to the big bad world.

    2. Re:code folding? by Trejkaz · · Score: 1

      Code folding is always the same... in practise it's no better than just looking over at the bottom left window, which shows all the methods and fields in your class. If anything it's a little more inconvenient because you need to keep opening things when you have to edit the insides.

      Really at this point the only thing that Eclipse could do to wow me would be fixing bugs like "application performance sucks", or "there is no Qt frontend." The latter of these I've been investigating lately by prodding the right people, and the former, well... that will take some time.

      --
      Karma: It's all a bunch of tree-huggin' hippy crap!
    3. Re:code folding? by rmull · · Score: 2, Informative

      Depends what you use it for. If you're folding up method definitions, sure it's the same thing effectively. But there are other places where it helps a WHOLE lot - like when you're using a GUI builder that puts gobs of generated code in different places. Just set it up to fold over the auto-generation delimiters it puts in the file and you can read your code much more easily. I've used it for that in VS.NET, with the gui builder. Eclipse's VE works in very much the same way, so it should be very useful there.

      It also works well with any other application where you have a horde of boilerplate code that you want to ignore but don't want to or can't factor out.

      --
      See you, space cowboy...
    4. Re:code folding? by Skjellifetti · · Score: 1

      Really at this point the only thing that Eclipse could do to wow me would be fixing bugs like "application performance sucks", or "there is no Qt frontend."

      or printing in Linux...

  3. Bah wrong eclipse! by gkelman · · Score: 0, Offtopic

    Was I the only one who read this and thought it was about the lunar eclipse that's just finished?

    Couldn't see much cos of cloud cover - I drove miles to get out to a decent location to take photos, for no good reason.

    Ah well. Fold your lunar eclipse code @home or something.

  4. Availability by jtheory · · Score: 3, Interesting

    I'm guessing this is only available in the nightly builds for now, since I just hopped over to the site and there's no sign of a new milestone release (would be M9).

    So... don't get excited -- the feature is *coded*, but you can't use it yet. That is, I haven't tried an Eclipse nightly before, but in general it's a bad idea if you're depending on the tool.

    It looks like the latest integration build (a step up from a nightly) is still failing its tests.

    In my experience, even some of the milestone builds have been a tad flaky (I put up with it because I want the features).

    Anyone involved in the project know anything about when the next milestone release is planned?

    --
    There are only 10 types of people: those who understand decimal, those who don't, and, uh, 8 other types I forget.
    1. Re:Availability by Dr_Java · · Score: 5, Informative

      The M9 Build is scheduled for Friday May 21, 2004 - its hidden away in the documentation. Full release of 3.0 is scheduled for July 2004.

    2. Re:Availability by maddin0 · · Score: 1

      Where did you find this information? I already searched through the whole eclipse site for a release schedule, but didn't find any...

    3. Re:Availability by plumpy · · Score: 2, Informative

      You have to go to "What's New History" and then scroll down to the Eclipse 3.0 plan.

      They keep updating it, but they never re-list it in the history for some reason, leaving it down in the news from last May.

      Here's a direct link.

    4. Re:Availability by tanksalot · · Score: 1

      FWIW I have been using M6 'in production' for awhile now and have not had any problems. I am looking forward for the stable 3.0 release though.

      --
      "I am not denying the existence of stupidity, or of stupid people." - phyruxus
  5. Hint for Emacs Users by AT · · Score: 4, Informative

    I know this article is about eclispse, but I'd like to point out this feature exists in emacs, too.

    Turn on hs-minor-mode (M-x hs-minor-mode) and code blocks can be folded and unfolded with shift-middle-click (or C-c @ C-c).

    1. Re:Hint for Emacs Users by Anonymous Coward · · Score: 0

      Jumping Jesus that's cryptic to the uninitiated (me)

    2. Re:Hint for Emacs Users by trouser · · Score: 1

      Very useful. Is there a way to save the fold state for a file b/w sessions?

      --
      Now wash your hands.
    3. Re:Hint for Emacs Users by Masa · · Score: 1

      I prefer outline-minor-mode. I have found out, that it works better with Tcl/Tk code. It has same keyboard commands as hs-minor-mode, but also supports hide-sublevels (C-c @ C-q) command (hides all hidable parts with one command).

    4. Re:Hint for Emacs Users by kwoff · · Score: 1

      Cool, I wondered about that after my colleague showed me you could do that in vim. I'll be remapping that command to something more reasonable now.

  6. first thing that I disabled in netbeans by Anonymous Coward · · Score: 2, Insightful

    It's funny that people are so happy about this feature. It was the first thing that I turned off in netbeans 3.6. It was a feature that I always wanted in a code editor until I used it and realized that it was only for people who don't read code.

    You need to see the code if you're going to write it or understand it.

  7. Eclipse and C++ by mattgreen · · Score: 1

    I downloaded Eclipse and the C++ tools but couldn't get anything like VS.NET's IntelliSense -- is it not supported for Eclipse? I use VS.NET 2003 regularly, but it has this aggravating tendency to freeze up for 5-10 seconds at a time very occasionally. That, and my project broke the IntelliSense, too. :)

    1. Re:Eclipse and C++ by notamac · · Score: 2, Interesting

      I'm a bit curious about Eclipse and C++ too. Whilst I'm not *so* concerned about intellisense (although something like Ctrl+P from Vim would be handy), the last time I downloaded the CDT, about 50% of my source code would crash the environment (put CPU usage up to 100% indefinately IIRC).
      So, that was about a year ago, and I've been a bit hesitant to try it again, despite the fact I really did like the Eclipse environment.

      Can anyone comment on how far the CDT has come in the last 12 months? Oh and also - is there any support for refactoring C++ yet :)

    2. Re:Eclipse and C++ by Gill+Bates · · Score: 4, Informative

      Can anyone comment on how far the CDT has come in the last 12 months? Oh and also - is there any support for refactoring C++ yet :)

      Not very far, AFAIKT. I used it a couple of months ago for some JNI/C++ code I was working on, and found that although it looks a lot like the Java editor, it behaves vastly different.

      No code completion, no code formatting, no refactoring.

      Just a basic code editor with color syntax highlighting.

  8. Re:Hint for Vim Users by dolmen.fr · · Score: 0, Redundant

    I'd like to point out this feature exists in emacs, too.
    And in Vim too.

    See :help usr_28.txt

  9. Feature requests, not bugs? by Guspaz · · Score: 3, Insightful

    Wouldn't support for code-folding and J2SE 1.5 features be feature requests, and not bugs?

    1. Re:Feature requests, not bugs? by Phil+John · · Score: 3, Informative

      Yes and no. Typically a lot of oss (and non oss) have one central place to track bugs and feature requests, it just makes it simpler for devs to check one source for what to do next.

      --
      I am NaN
    2. Re:Feature requests, not bugs? by Trejkaz · · Score: 1

      Oh boy. In the topic of J2SE, IntelliJ IDEA had (albeit experimental) support for 1.5 over half a year ago (was it longer? It might have been a whole year by now.)

      I wish that the new Eclipse would have support for the Java which is emerging at the time it comes out.

      People often start developing an application while the SDK or APIs they're using are in beta because by the time the app is finished, the API will be in final release. But right now there is no free IDE for editing J2SE 1.5 code (unless you count VIM... but VIM isn't really an IDE.)

      What a pain.

      Hopefully they at least format generics correctly instead of reporting them as syntax errors. I can wait for the full feature set for 1.5 but if it's going to mark my code as invalid then it can GFI.

      --
      Karma: It's all a bunch of tree-huggin' hippy crap!
    3. Re:Feature requests, not bugs? by plumpy · · Score: 3, Informative

      They've been planning the 3.0 release for over a year, so they're not going to hold it up to get Java 1.5 support in.

      That said, 1.5 support is coming along and development versions can be installed as a plug-in (that link will also show you the current status).

      Once it's complete, I'm sure it will be included in an Eclipse point release. 3.0.2 or 3.1 or whatever.

    4. Re:Feature requests, not bugs? by Anonymous Coward · · Score: 0

      doesn't sound like very good planning if they didn't know Java was going to have generics.. duh!

  10. questionable features by f00zbll · · Score: 5, Insightful
    although the feature is useful and many programs have them. For example several HTML editors have this feature, since many html pages have tons of tables. Having folding is great for documents that are long like HTML. For code I feel it tends to lead to bad habits.

    For example, most of the .NET programmers I work with are x-VB guys and they use this alot. what ends up happening is they put all the classes in one file. Which actually leads to a tendency of coding with lots of inner classes. One of the biggest strengths of Java in my mind is it encourages programmers write smaller chunks of code that is more modular and re-usable. If you write your code in a well organized manner, you won't really need folding. Especially since the right pane in Eclipse shows you the methods and allows you to double click and jump to that point quickly.

    I read the bug/feature requests and many of the arguments in my mind are personal bias. they aren't really valid. Several people complained Eclipse wasn't usable because it didn't have folding. I question that way of thinking and suggest the user is inflexible and unwilling to adapt. If it's that important, then write it yourself and submit it to eclipse. Needless whining serves no one any good. The time spent whining could be spent coding.

    1. Re:questionable features by DrEasy · · Score: 1
      For example, most of the .NET programmers I work with are x-VB guys and they use this alot. what ends up happening is they put all the classes in one file. Which actually leads to a tendency of coding with lots of inner classes. One of the biggest strengths of Java in my mind is it encourages programmers write smaller chunks of code that is more modular and re-usable. If you write your code in a well organized manner, you won't really need folding.
      Interesting point. Maybe what should be done to support code folding while encouraging the habit of writing many small classes would be to have a UML view, where you could "zoom in" a class to display its code while keeping the UML view of related classes around it. Code would unfold as you "zoom in" more and more... (and vice-versa)

      The one problem with that approach might be that it would take up a lot of screen real estate, but then again that would encourage people to organize their classes in smaller packages.

      So far all the "roundtrip" approaches I've seen that combine an IDE with UML (Rational Rose, Together, Eclipse + Omondo) are quite clumsy. You end up using the tool either for UML design purposes or to program, but never both. Considering a UML class diagram view/perspective as an extension of a code folding feature might be what they've been all missing.

      --
      "In our tactical decisions, we are operating contrary to our strategic interest."
    2. Re:questionable features by ClosedSource · · Score: 2, Funny

      "Several people complained Eclipse wasn't usable because it didn't have folding... Needless whining serves no one any good."

      Since the desired feature was implemented, the "whining" was apparently quite effective.

    3. Re:questionable features by Bitsy+Boffin · · Score: 1

      I can't speak for Java (long time ago now), but code folding makes writing OO PHP a whole lot nicer.

      PHP has no preprocessor "include" statement, so short of splitting your method bodies into other files using the execution time include statement which brings a performance penalty on every call to the method, you often wind up writing huge monoliothic classes full of relevant methods rather than nicely splitting them into smaller files and using a preprocessor directive to include them.

      I have my editing environment (jedit) set so that it folds-on-open down to showing just the class, properties and function headers, i can quickly skip through the file find the method I want to look at and hit my keyboard shortcut to expand the folded code completely, when I'm done with that method, just another keyboard shortcut and I only see the function header again.

      Of course, it would be nice if PHP had a preprocessor include directive too, but it doesn't.

      --
      NZ Electronics Enthusiasts: Check out my Trade Me Listings
    4. Re:questionable features by erlando · · Score: 1
      What?! How can you talk about preprocessing and PHP? It's a scripting language. It's all execution-time processing, especially in regard to includes.

      What you really want is C-style preprocessing. The fundamental difference here is that in C the code gets compiled and therefore preprocessing makes sense. Unless PHP steps up from being interpreted files to being binary executables, what you are talking about makes no sense.

      --
      Remember, there are no stupid questions. But there are a lot of inquisitive idiots.
  11. NetBeans has it in 3.6 (the stable release) by LoveMe2Times · · Score: 1

    Just wanted to point out that NetBeans also has this feature in the recently released 3.6. You don't have to wait until an "official" Eclipse release; you can use a stable NetBeans now. Obviously, I like NetBeans, and I think they've been making leaps and bounds of progress recently. I'm really looking forward to 4.0 with the Ant based project system. Then, you should be able to work in either NB or Eclipse, or Emacs or whatever floats your boat. Hooray for competition!

    Also, for those saying this leads to bad coding style, I'm hoping that the forth-coming refactoring features in NB 4.0 will make this much less of an issue (don't know about Eclipse equivalent feature). Got a junior dev who likes to make really really long code blocks? Refactor into saner functions with a little help from your IDE. Since I'm about to get some junior devs dumped on me, I hope it does work out...

    1. Re:NetBeans has it in 3.6 (the stable release) by Trejkaz · · Score: 1

      Does NetBeans 3.6 have J2SE 1.5 support as well? I'm curious since I'm playing with it and may end up using it for a real app Real Soon Now.

      --
      Karma: It's all a bunch of tree-huggin' hippy crap!
    2. Re:NetBeans has it in 3.6 (the stable release) by Anonymous Coward · · Score: 0

      Whoah, NetBeans 3.6 doesn't look like complete fucking ASS anymore. Nice. Maybe I'll give it a shot.

      FWIW, Eclipse 2.x has some decent refactoring support. 3.x has even better. Even 3.x isn't as good as IDEA, but it's not bad, either.

  12. -1 Not Funny by bartok · · Score: 1

    -1 Not Funny

  13. Bugzilla by bcore · · Score: 2, Interesting

    Very often OSS projects use Bugzilla to track problems and requests for enhancements. To bugzilla, the fundamental unit (whether it's a defect or an RFE) is called a Bug.

    Therefore, when they call it "Bug 9399", they are just referring to the entry in bugzilla with that number.

  14. IDEA by tpv · · Score: 2, Informative

    For those who dislike the implementation, it is recommended that you use IntelliJ IDEA, rather than resubjecting yourself to a world of pain.

    --
    Read more of this story at Slashdot.Read more of this story at Slashdot.Read more of this story at Slashdot.
  15. Missing the point of good OO code? by dashersey · · Score: 1

    I thought the reason eclipse didn't support easily collapsing and browsing 100's of line of code had to do with lack of need vs other non-java IDEs. Why would an effective java programmer generate methods with 100's of lines of code that need summarizing? Such methods are known to be error-prone and hard to read and understand. This is why we refactor complex methods into smaller, more focused methods. Once this is done, the package explorer and outline views are much more effective than code folding would be, since they allow navigation at the semantic level (assuming you've chosen good method names). It disturbs me that there is so much demand in the java community for a feature that would be most useful in a language that failed to express the power of OO.

    --
    You are in a maze of twisty little passages; all alike.
    1. Re:Missing the point of good OO code? by Gr8Apes · · Score: 1
      Code folding would be extremely nice for comments, imports, and the case where you inheret someone else's really really bad code (read as 100s of lines in a single method).

      Otherwise, truly well written OO code would rarely even lend itself to code folding.

      --
      The cesspool just got a check and balance.
  16. Code Density by kmsigel · · Score: 2, Funny

    I have never used code folding. What I do is (of course) try to keep basic blocks short and focused. In addition, I make my code dense by putting multiple short statements on one line if they are related. (Statements that appear near each other are usually related.) I also place a group of several short statments that are the target of an if/while/etc on the same line as the if/while/etc.

    What this does is fit a lot more code in the same number of lines (not recommended for LOC whores), meaning you see a lot more code on screen at once.

    Here is an example of code I wrote yesterday:

    KError error; ichar c;
    Loop: if (error = Read(&c)) return error;
    if (KIsFlagSet(readMode,fModeAuto)) {
    if (KIsFlagSet(readMode,fModeTwo)) {
    if (KIsFlagSet(readMode,fModeCR)) {
    if (c == CR) { readMode = cModeTextLFCR; goto Loop; }
    else readMode = cModeTextLF;
    } else {
    if (c == LF) { readMode = cModeTextCRLF; goto Loop; }
    else readMode = cModeTextCR;
    }
    } else if (c == CR) {
    readMode = cModeTextAuto | fModeTwo | fModeLF; c = LF;
    } else if (c == LF) {
    readMode = cModeTextAuto | fModeTwo | fModeCR;
    }
    } else if (c == CR) {
    if (KIsFlagSet(readMode,fModeCR)) c = LF;
    else if (KIsFlagSet(readMode,fModeToss)) goto Loop;
    } else if (c == LF) {
    if (KIsFlagClear(readMode,fModeCR)) ;
    else if (KIsFlagSet(readMode,fModeToss)) goto Loop;
    }

    1. Re:Code Density by Anonymous Coward · · Score: 0

      +1 funny, +1 sad

      Thanks for coming out.

    2. Re:Code Density by kmsigel · · Score: 1

      +1 funny, +1 sad

      Please explain. You don't like the way I code? It has served me very well for many years.

      You may complain about the absence of comments, but the code I posted was almost the entire function. The purpose of the code is very clear from the function title. Besides, comments just lower the code density and prevent me from seeing as much code per screen.

      I realize that my style isn't necessarily good for programmers working as part of a team. I am always the sole programmer on projects I work on.

    3. Re:Code Density by turgid · · Score: 2, Funny

      Argh! It's FORTRAN written in Java! Quick, sprinkle the Holy Water...

    4. Re:Code Density by Anil · · Score: 1
      It is just harder code to read than what most programmers are used to. It isn't 'skim' friendly. I can read it and understand it, but there isn't always time to read every single character in a method - I expect to be able to look at every line quickly and see what is going on.

      The main problem is that there are some changes that are not apparent if you were to skim the method. For example:
      readMode = cModeTextAuto | fModeTwo | fModeLF; c = LF;

      On a quick skimming of the method the "c = LF" statement would probably be missed. This would cause confusion later when the variable is used. Sure, at that point someone could just use the search tool to find the "c =" line, but still, it takes that extra effort.

      Using whitespace isn't bad. It is ignored by the compiler anyway, it is there for the benefit of the reader. Having extra line breaks to facilitate reading is a good thing.

      But, hey, if your style works for you, use it. Just remember that it might not fly so well when working with a team of other programmers. I must admit, I used to be a fan of code density, too (though not to your extent) back when I was just using vim on a console terminal. More concerned about readability now that I use 2 to 8 vim windows under X.

    5. Re:Code Density by BubbleNOP · · Score: 1

      Firstly, you may want to read Dijkstra's "Go To Considered Harmful". Secondly, your code is full of redundancies. What you are doing can be captured much more clearly by a finite state automaton with an alphabet and transition table. Finally, because of how this is written, it is completely unconvincing that it is bug-free, even if every line was commented.

    6. Re:Code Density by kmsigel · · Score: 1

      First, I'd like to thank you for such a thoughtful reply.

      It is just harder code to read than what most programmers are used to.
      The main problem is that there are some changes that are not apparent if you were to skim the method. For example:
      readMode = cModeTextAuto | fModeTwo | fModeLF; c = LF;


      These are good points. I am used to my style, so when I go back and read my own code I pay attention to the entire line. I readily admit that this style isn't necessarily good for situations where others will regularly look at your code.

      Having extra line breaks to facilitate reading is a good thing.

      Your point is valid and applies to many (maybe most) programmers. For me, however, having extra line breaks makes it harder for me to see the bigger picture and understand more of my code at once.

      Just remember that it might not fly so well when working with a team of other programmers.

      I don't like to work on projects that involve other programmers. Since graduating from college (in 1993) I have never worked on such a project.

    7. Re:Code Density by kmsigel · · Score: 1

      Firstly, you may want to read Dijkstra's "Go To Considered Harmful".

      I am aware of the arguments against goto. I could have easily wrapped the main portion of the code in a loop and then used break and continue when needed. In fact, that's what I did at first. I then decided that I liked the goto implementation more.

      Secondly, your code is full of redundancies. What you are doing can be captured much more clearly by a finite state automaton with an alphabet and transition table.

      Can you give a quick example of what you mean?

      Finally, because of how this is written, it is completely unconvincing that it is bug-free, even if every line was commented.

      Fortunately, the only person I need to convince is me! :)

    8. Re:Code Density by theefer · · Score: 1

      I am aware of the arguments against goto. I could have easily wrapped the main portion of the code in a loop and then used break and continue when needed.


      My programming teacher plainly told me that the less break/continue you use, the better the code. Basically, he argued that if your code is perfectly clean, you don't need them.

      At first I was a bit unsure, but after a few lessons, and now after learning functional languages, I see that sometimes clever approaches make for much cleaner code.
      --
      theefer
    9. Re:Code Density by arohann · · Score: 1

      I don't like this.
      I know that everybody has their own style but I work in a commercial organization that writes Enterprise software and I can tell you that this would not have passed our code reviews.
      1- The formatting is too tight. Not enough white space.
      2- Complete absence of comments (big boo boo)
      3- Poor indenting (affects readability)
      4- Multiple statements on one line (usually a bad idea)

      --
      ....In a world without walls, who needs Windows ?
    10. Re:Code Density by kmsigel · · Score: 1

      I don't like this.
      I know that everybody has their own style but I work in a commercial organization that writes Enterprise software and I can tell you that this would not have passed our code reviews.


      I have already stated that this style probably isn't right for most people. It works well for me and since I work alone nobody else has to see it.

      1- The formatting is too tight. Not enough white space.

      I like it precisely because it is tight.

      2- Complete absence of comments (big boo boo)

      Comments often times only get in the way of understanding the code, especially when a function is fairly small and has an easily understood purpose.

      3- Poor indenting (affects readability)

      The indenting is what I like. (Note that I left justified all lines to fit better on the /. screen.)

      4- Multiple statements on one line (usually a bad idea)

      I specifically like to put multiple related statements on one line as long as they fit within 80 columns. If you are expressing one larger idea why not put it all on one line?

      Thanks for the comments.

    11. Re:Code Density by Anonymous Coward · · Score: 0
      It's FORTRAN written in Java!

      Java doesn't have a "goto" statement. His code does.

    12. Re:Code Density by turgid · · Score: 1
      Java doesn't have a "goto" statement. His code does.

      Really? I must learn Java properly some time. I just assumed it must have one.

    13. Re:Code Density by pyrrhonist · · Score: 1

      OMG! You're an "else cuddler". That's just not right! :)

      --
      Show me on the doll where his noodly appendage touched you.
    14. Re:Code Density by AvantLegion · · Score: 2, Funny
      Argh! It's FORTRAN written in Java!

      <p>
      Don't worry - Java's garbage collector will take care of that garbage...
      <p>
    15. Re:Code Density by atlacatl · · Score: 1

      I don't like to work on projects that involve other programmers. Since graduating from college (in 1993) I have never worked on such a project.

      In software development the "me/I/my" code doesn't work well in large development projects or anything close to trying to implement any type software engineering practices. Once you start owning the code in the sense that you don't care who else reads it, the code is already non-useful for future enhancement.

      Also, there are different reason one develops programs. On the one hand, there is the extension of the developer in the code, in the sense that it becomes art to be preserved for the duration of the program, and hence the ownership of the code in the form of ego gratification. On the other hand, and most importantly, is that the program is developed for someone else: a client (Paying or not, it makes no difference). There is always a stakeholder in the process, and coding unreadable code (I.e. only one developer can read it) is doing a disservice to the client and should advice that in the case that "you" decide to not work on the project any longer or your firm disappears, they will end up with a project that will need to be reworked by a new individual/group. That's an extra expense.

      Again, since you put your code for thousands of reviewers, don't take anything said here too harshly. I'm sure we are only trying to help for you to become a better developer and more profitable.

      In that note, buy any type of University level Software Engineering book and read (thoroughly) the OO design chapter - Software methodologies haven't changed much since '93, however, in 11 years there are many writers and developers who have written good books on our chosen trade...

      --
      Esta es una firma en Espanol.
    16. Re:Code Density by kmsigel · · Score: 1

      In software development the "me/I/my" code doesn't work well in large development projects or anything close to trying to implement any type software engineering practices.

      As I've already said, I'm not interested in working with others. I'm only interested in working alone. If somebody wants to work on (or with) my code they can do so, but on my terms. This has happened several times with my clients, and after the initial steep learning curve they have successfully understood and modified my code. They have even come to appreciate my design and style.

      Once you start owning the code in the sense that you don't care who else reads it, the code is already non-useful for future enhancement.

      I don't agree. I'm not specifically trying to make the code hard to read or hard to maintain. I'm making it easy for me to read and easy for me to maintain. There are others like me, and people who aren't can learn to deal with my style if they must work with my code.

      On the flipside, it drives me nuts to look at code that is sparse. Code that has blank lines and/or only one trivial statement per line annoys me. Even worse is when every line has a comment (on a separate line, of course) that says something like, "Now we increment the pointer." As if I couldn't figure that out from "p++;"!

      While this annoys me, I don't tell those people that they should code like me. I simply don't look at and/or use their code unless I really have to. Fortunately for me, I almost never have to.

      Also, there are different reason one develops programs.

      That's a good point. At this point in my career, I only do things because I think they are fun. People who hire me understand that I'm not really a typical programmer.

      Again, since you put your code for thousands of reviewers, don't take anything said here too harshly. I'm sure we are only trying to help for you to become a better developer and more profitable.

      I do appreciate all of the comments and I'm not offended by any of them. I enjoy the debate. I am always trying to be a better developer, believe it or not. :)

      In that note, buy any type of University level Software Engineering book and read (thoroughly) the OO design chapter - Software methodologies haven't changed much since '93, however, in 11 years there are many writers and developers who have written good books on our chosen trade

      I did learn OO design in college. I feel that I understand the fundamentals pretty well. I'm not that into reading books that try to tell me how to do things. I find that it prejudices me towards a particular solution. I get pleasure from doing things "from scratch."

      Thanks for the comments!

  17. Mac compat by scrotch · · Score: 1

    I hope they're working to make Eclipse more Mac compatible. I'm using it on my Powerbook. It's great, but soooo many of the dialog layouts are way off. Things resize poorly and are often totally different and innapproriate sizes. Text starts to the left of the text boxes that hold them, so that I've got to click in the box and scroll left to see the beginning. It's crazy. I guess it's all SWT's fault. Does anyone know if this is being worked on?

    1. Re:Mac compat by Triskele · · Score: 1

      This is probably not the answer you're looking for - but NetBeans works very well on a Mac as it uses Swing not SWT. NetBeans vs Eclipse is a real case of swings and roundabouts. For some things I prefer Eclipse (better autocompilation and error detection and better execution targets) but in other ways I prefer NetBeans. Give NetBeans a whirl - it may work for you.

      --

      --
      USA: home of the world's largest terrorist training camp.

  18. Nope. Just dealing with certain realities. by Prior+Restraint · · Score: 3, Insightful

    Why would an effective java programmer generate methods with 100's of lines of code that need summarizing? Such methods are known to be error-prone and hard to read and understand.

    That's what I keep saying to my coworkers. Nevertheless, we have methods over a thousand lines long, and our largest class is hovering around 25kloc (and I assure you, there's little reason for most of that code to be in the same class).

    If nothing else, code folding is an effective tool for when you're forced to maintain source code written by idiots.

    1. Re:Nope. Just dealing with certain realities. by dashersey · · Score: 1
      Ouch! I personally find that test-driven development is a helpful approach to dealing with such legacy behemoths... there is some up-front catch-up work but it's usually possible to a) keep it focused on the task at hand and b) make at least some of the code simpler (read: better-factored) than it was.

      Or you could just run a java-to-vb cross compiler and replace your entire staff with high school students ^^-)

      --
      You are in a maze of twisty little passages; all alike.