Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Announcements Programming IT Technology

First Commercial C++ Development Refactoring Tool 63

swrittenb writes "According to their recent press release, SlickEdit Inc. announced Visual SlickEdit® v9, the first commercially available development tool with C++ refactoring. Although this area has been studied, and non-commercial refactoring tools for C++ exist, how comfortable are people using an automated solution for refactoring with this particular language?"
This discussion has been archived. No new comments can be posted.

First Commercial C++ Development Refactoring Tool

Comments Filter:
  • by NEOtaku17 ( 679902 ) on Friday April 30, 2004 @02:53AM (#9016420) Homepage
    http://www.refactoring.com/tools.html
  • by orthogonal ( 588627 ) on Friday April 30, 2004 @03:14AM (#9016471) Journal
    how comfortable are people using an automated solution for refactoring with this particular language?"

    Well, when you consider that a compiler is also "an automated solution for [code] refactoring", I guess anyone using C++ (or any other compiled language) is reasonably conformable.

    Since there are no constructors or templates or multi-expression tests ( "if( a && b || c && d )") in any machine's assembly languages, we all trust our compilers to generate assembly language that corresponds to the high-level language constructs we've actually written -- and in the case of the control expression to that "if" statement, we trust the compiler to know and follow the operator precedence for the language being compiled -- and in C and C++, the required "short-circuit" evaluation too.

    That said, a good bit of that trust -- for C++ and C -- reposes in rigorous language standards and (more or less, I don't want to argue about language (mis)features or hacks for backward compatibility) well thought-out language designs.

    (That's one of the many benefits of a rigorous, documented language standard, by the way -- do you know if, in scripting language "S"( where "S" may be Perl, windows scripting host, visual basic, or what have you), short-circuit evaluation of logical operators takes place, or if there's a sequence point between each one? Not to bash any one language, but for Perl, deja-googling shows sequence points have been an unresolved issue since 1998.)

    To the extent that a refactoring tool's design is based on standards and on thoughtful and an open -- not proprietary -- processes that bring in opposing and skeptical views, as do the design of C and C++, I'd be reasonably willing to, in Reagan's words, "trust but verify". But if the refactoring tool is the proprietary product of a closed shop, I'll be far less confident that the Marketing Department didn't;t have too much of a had in product "design".

    But however the products comes to be, the proof remains in the use -- let's see how the automatic refactoring compares over several real-life projects before trying to judge.
    • by Anonymous Coward on Friday April 30, 2004 @05:20AM (#9016825)
      Well, when you consider that a compiler is also "an automated solution for [code] refactoring", I guess anyone using C++ (or any other compiled language) is reasonably co[m]for[t]able. (I assume that's what you meant.)

      Nope, it's not the same thing at all. The transformation from high-level to low-level code is much simpler than the converse; that's why you can't decompile a native-code executable, even an unstripped one, and get beautifully formatted and readable code out of it.

      I trust my compiler to output valid machine code precisely because machine code is so simple. C++ is very complicated; if I were a C++ programmer (which I'm not, I prefer simpler and safer languages) I'd definitely be keeping backups of my unrefactored work for a while.
    • Not to bash any one [scripting] language...

      Ha, good one!
  • by Anonymous Coward
    They way things seem recently they'll file a patent in short order.

    Personnally I think pico, nano, and notepad are the best refactoring tools out there, and two of these were commercial apps so I don't see how this is the 'first' commercial refactoring tool.
  • by trouser ( 149900 ) on Friday April 30, 2004 @04:08AM (#9016597) Journal
    I, for one, am extremely uncomfortable with the idea of automated code refactoring in C++ for a number of very good reasons most of which have to do with those little yellow post-it notes that people keep leaving on my monitor with words like 'the' and 'when' written all over them in increasingly small, or decreasingly large, handwriting which makes me very nervous indeed.

    Thank you.
  • SlickEdit. (Score:5, Interesting)

    by Spudley ( 171066 ) on Friday April 30, 2004 @05:21AM (#9016829) Homepage Journal
    I've used SlickEdit for a while, and it is a very nice tool (even if we call it SlackEdit at the office). Their Diff tools (DiffZilla, etc) are probably the best I've used anywhere.

    I've only had the chance to use it under Windows, but I understand there's Unix and Linux versions available too.

    My opinion: If you're going to pay for an editor, this is a good one to pick.

    When it comes to refactoring, I can't comment - I've not used this version, so the feature is new to me. It sounds like an interesting feature, but in honesty, I can't see us making much use of it.
    • Agreed. I have been using VS 5.0 for the past 4 yrs and love it. It really shines when you have a large code base, files scattered everywhere, and need to get up to speed on how the code works in a very short amount of time. Bob
  • Sure, why not. (Score:3, Insightful)

    by ndykman ( 659315 ) on Friday April 30, 2004 @05:24AM (#9016842)
    I don't have a problem with any refactoring tool if it allows me to see what changes it made (Kind of a no-brainer), and allows them to be undone if the results aren't too great after you do it. Even better is if they integrate with a tool's undo or redo, if they are hosted in an IDE like VS .Net, JBuilder, Eclipse, etc.

    Sure, it's tricky to insure that more complex refactorings do what they say, and sometimes they do change the semantics, but in a way you want. For example, moving methods up/down in a hierarchy.

    And the simple refactorings are still really useful. Rename X is just really, really nice.
  • What I want (Score:5, Insightful)

    by geirt ( 55254 ) on Friday April 30, 2004 @05:58AM (#9016947)

    I want a syntax cheker running while I am editing the source code.

    Example 1: When I am writing: "printf("Hello %d\n", "world");" I want a red line under "world", with a mouse-over stating: "Integer, not string expected in printf format string". I want this to happen while i type.

    Example 2: When writing: sinus(3.14); I want a red line under sinus(), with a mouse over explaining "Call to function sinus() without prototype" without running the code trough a compiler.

    I also want sane syntax highlighting. I want it to highlight the things that I look for when I am browsing trough lost of code. That is my function and variable names. All other should be kept in low key (eg. if while for int struct etc.). I am not sure if i want call to libc to be highlighted. Show me the important stuff, not the cruft! Editors are not too bad on this (or can be customized), but when I press print in emacs or use gnu enscript, it prettyprints all the wrong things, and hides away the important stuff.

    • Re:What I want (Score:2, Insightful)

      by WasterDave ( 20047 )
      Example 1: When I am writing: "printf("Hello %d\n", "world");" I want a red line under "world", with a mouse-over stating: "Integer, not string expected in printf format string". I want this to happen while i type.

      Yeah, agreed, it would be savage. I'm busy, so you go code it up and I'll buy it. A plug in to XCode would be wonderful, thanks, and while you're at it do *something* to make all the other pop ups work properly.

      Gawd, all the shit about CASE tools, you would have thought someone like Rational wo
    • by Anonymous Coward on Friday April 30, 2004 @06:45AM (#9017073)
      ..I want a syntax cheker..
      ..running the code trough a compiler
      ..I am browsing trough lost


      [cheapshot]
      I can't imagine why you feel you need a checker for the code that you type..
      [/cheapshot]
    • Re:What I want (Score:2, Informative)

      by achesloc ( 697690 )
      Eclipse http://www.eclipse.org does something akin to what you describe. I am not sure if it will work for anything except java. Check it out.
    • Re:What I want (Score:2, Informative)

      by jergh ( 230325 )
      Since you're using emacs you might want to take a look at Flymake [sourceforge.net] -- "an on-the-fly syntax checker for Emacs".

      Description reads as:
      Performs on-the-fly syntax checks of the files being edited using the external syntax check tool (usually the compiler). Highlights erroneous lines and displays associated error messages.
    • That is my function and variable names. If you're using any kind of decent editory, just change the fonts/colors it uses.
    • You toss around demands like "while I type" and "without running a code through a compiler." Now tell me just what you think is going to be doing the checking.

      Detecting the examples you gave require at least a parser, and some minimal semantic analysis. Parsing takes up the bulk of compiling time in C and C++, and you're not going to get that in a heartbeat.

      How often is this mini-compiler supposed to check your code? Constantly? It'll be siliently getting errors in the background, as it waits for y

      • I can't speak for C++, but in the Java world most of these checks are built into the IDEs. Eclipse needs to compile the source to show most errors (which it does every time you save a file). It's a bit of a pain in my opinion. I've gotten used to IntelliJ IDEA, which parses the file with every keystroke. I assume it doesn't do this from scratch each time, since it's still very responsive. It also keeps some sort of index in memory so it can quickly show bindings to other source code (this method is an
      • I agree. Yes, parsing is expensive, but it isn't so expensive that it can't be done. Word does spell and grammatical checking on the fly. Electronics design software does "on the fly" forward and backward annotation while you work (checking that the circuit layout is consistent with your schematics). I have no problem understanding that the editor needs to do a lot of what is requires by a compiler. But it can be done.
        • that the editor needs to do a lot of what is requires by a compiler.

          The smart way to do this, of course, is by making the editor able to share a front-end with the compiler itself. Possibly even make them all part of the same program, like many of the IDEs.

          I know of a variant on GCC where the front-end would dump a kind of XML representation of the program's identifiers, for cross-reference building. An editor would better off asking the compiler to do the work like that, rather than doing it on it

          • man, i found a few cool things in this discussion. flymake [sourceforge.net] seems interesting but gcc_xml [gccxml.org] is extremely interesting!! while a great app for other languages, i am not a big fan of [ec]tags for c++ because of the richness of object-orientation as opposed to c. regular expressions just wont cut it for c++, you need to understand the semantics of the symbols in the program.

            my master's thesis defended that as an editor there is nothing wrong with gnu/emacs that a "next-generation ctags" couldn't fix - and a few
      • Parsing is expensive. There's a reason why syntax highlighting doesn't go beyond heavy regexing.

        It's worth noting that in Eclipse (and from what I gather, most other IDEs), the assistance provided is done not on the basis of a full file reparse each time something new is typed. Rather, the IDE keeps the parse around after the initial parse, and when it notes that a portion of the document has changed, it usually is able to get away with just reparsing a small area around what was changed, and modify it'
  • by Decaff ( 42676 ) on Friday April 30, 2004 @07:49AM (#9017227)
    IBM's VisualAge C++ has been around for a long, time. All the VisualAge products include powerful refactoring tools.
  • I just took a look at the specs and found the "refactoring"-features:

    - Rename
    - Extract Method
    - Encapsulate Field
    - Convert Local to Field
    - Convert Global to Field Instance
    - Convert Static Method to Instance Method
    - Move Static Field
    - Move Method
    - Replace Literal with Constant
    - Create Standard Methods
    It does not seem overly complicated to me, to implement these.

    Most of the features are simple search and replace operations. Just add some knowledge the compiler would have to the editor and it bec
    • by manavendra ( 688020 ) on Friday April 30, 2004 @09:40AM (#9017906) Homepage Journal
      Most of the features are simple search and replace operations. Just add some knowledge the compiler would have to the editor and it becomes quite easy to do

      hmm... lets examine them then.

      Rename
      So say you want to rename A::foo() to A::bar(). But foo() is private - so the tool has to look only in the current file, while for protected the file and its children, while the entire project if its public. While its rather easier to limit private and public members, how about protected? What if there is B::foo() as well? what if B::foo() is used in A?

      Extract Method
      This usually works when you select a piece of code and want to extract it to a method. search and replace? umm yes. How about the method sanctity? Wouldnt the tool need to ensure your extracted method is remains unbroken? what about the variables used in the selected segment? Are they declared within the selection?

      Convert Local to Field
      A::foo() has "myLocal", and so has A::bar(). Upon refactoring, should "myLocal" be replaced within with the new field in A::bar() as well?

      Convert Global to Field Instance
      A::Global is made a field. But A::foo() has a local variable Global defined as well. Should the tool do its job silently or inform you about this?

      Convert Static Method to Instance Method
      ditto

      I haven't read the specs of the tool, so I don't really know if it performs all this validation. I sure hope it does, if they want to sell it to anyone else other than mom and pop

      Just my $0.02
      • > What if there is B::foo() as well? what if B::foo() is used in A?

        B::foo() is a completely separate function from A::foo() and should not be renamed. It is easy to tell which one A wants to call because the call method would differ (b->foo() as opposed to foo()).

        > A::foo() has "myLocal", and so has A::bar(). Upon
        > refactoring, should "myLocal" be replaced within
        > with the new field in A::bar() as well?

        No. myLocal in bar() is used for a different purpose from the one in foo(). There is no
        • Oh I absolutely agree with your observations. I am in no way disinclined about the tool having to think and make informed decisions when replacing methods, variables and selection blocks and based upon access modifiers

          I was just elaborating on the fact that such a refactoring tool is more than search and replace, as was mentioend.

          IMHO, refactoring tools make can be quite useful in tidying up the code, be it yours or written by someone else. However, to categorize them as a glorified search/replace t
        • What if there is B::foo() as well? what if B::foo() is used in A?

          B::foo() is a completely separate function from A::foo() and should not be renamed. It is easy to tell which one A wants to call because the call method would differ (b->foo() as opposed to foo()).

          Sure, but what if you had 'x->foo()'? You have to know the type of variable 'x'. This is not a simple search/replace operation, unless you can do type analysis with a regex (you can't). Then again, maybe your editor does search/repl

          • > what if you had 'x->foo()'? You have to know the type of variable 'x'.

            Sure. The compiler needs to know it too, so all the necessary headers will already be included.

            > This is not a simple search/replace operation, unless you can
            > do type analysis with a regex (you can't).

            If you intend to write your tool entirely in regex, good luck to you. You already need some type analysis to match types to variables for field extraction. Parsing type declarations is not that difficult and then you just m
            • If you intend to write your tool entirely in regex, good luck to you. You already need some type analysis to match types to variables for field extraction. Parsing type declarations is not that difficult and then you just maintain a type tree and look things up when you need them. Really, if you have ever write a compiler, you'll discover that it is one of the simpler parts of the project.

              The original post suggested that the marketing department was giving fancy names to simple search/replace operati

    • These are menial changes -something you should have done in the first place. Actual refactoring means changing the way the code works, not the way it's laid out.
      • Not really (Score:3, Informative)

        by manavendra ( 688020 )
        From Refactoring.com [refactoring.com]

        What is Refactoring?

        Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. Its heart is a series of small behavior preserving transformations. Each transformation (called a 'refactoring') does little, but a sequence of transformations can produce a significant restructuring. Since each refactoring is small, it's less likely to go wrong. The system is also kept fully working after eac
  • by 4of12 ( 97621 ) on Friday April 30, 2004 @09:01AM (#9017565) Homepage Journal

    how comfortable are people using an automated solution for refactoring

    A fair number of proficient C++ programmers make a great living refactoring other peoples' mistakes.

    In an average project, most objects and methods are still damn far from being prime.

    • Well I understand the concerns about security, but if you have ever used such tools (and you probably might have), you'd find that these are not some "magic" tools that would do all the refactoring work for you.

      1. These tools don't make decisions about what to refactor - you tell them what has to be done, they just do it for you.
      2. Humans tend to introduce errors in tedious, monotonous situations.

      Proficient C++ programmers are paid and valued for the knowledge they bring with themselves, which is
    • In an average project, most objects and methods are still damn far from being prime.

      Tell me about it. I'm a self-taught amateur who's trying to write a fairly complicated piece of software, and I can tell you that my code is far from being 'prime'. Lots of stuff that would be better as templates, or just resolving a pointer and passing it as a ref to an equivalent function ( i.e. operator=(myObject&) and operator=(myObject*) ) instead of rewriting what amounts to the same function only with a point

  • by Chemisor ( 97276 ) on Friday April 30, 2004 @10:26AM (#9018394)
    > How comfortable are people using an automated
    > solution for refactoring

    It is not possible to automate (as in "without any human intervention") refactoring because it requires understanding how the entire project works. Any tools you create may help, but they do not obviate the need for thinking and redesigning, the two tasks the computer is incapable of doing.
  • ... if you read the description of the features [slickedit.com] that they've added, it isn't as impressive (to me, at least) as you would believe from the magic moniker "refactoring". They merely provide automation to refactoring tasks you could do by hand but which are more time consuming.

    The comparison with a compiler is specious. Perhaps a better comparison would be to a macro assembler. But even then, the fact is the editor is not doing anything more than the body sitting on the other side of the keyboard.

    What woul

  • I thought together supports C++ refactoring, but I have only used it for C#. I can't afford the full blown version :(

    Quoting:

    "Refactoring
    Support for Refactoring at Class, Attribute and method level. Refactoring means rewriting existing source code with the intent of improving its design rather than changing its external behavior. The focus of refactoring is on the structure of the source code, changing the design to make the code easier to understand, maintain, and modify. The primary resource book on ref
  • A major drawback for using this tool is the company deliberately makes it hard to find the documentation to use the tool for novices, you cannot find it on their website. Getting a simple c++ program to compile on this can be nightmare to a new user.
    Here is one place that sells the documentation

    http://www.programmersparadise.co m/Product.pasp?txtCatalog=Paradise&txtCategory=&t x tProductID=M39+017W
    Their website does not sell the their own documentation.

With your bare hands?!?

Working...