News for hackers. Stuff that matters.
Re:Generating a Java program with 90% less code by philwelch on Wednesday December 04, 2019 @12:21PM (#21704274)
With a statically typed language and an IDE this isn’t a real issue. There’s no “edge case” when you rename a class or method symbol in a Java project because the IDE deterministically knows what are the invocations of the same symbol.
Re:Generating a Java program with 90% less code by TeMPOraL on Wednesday December 04, 2019 @01:33PM (#21705321)
Except when you use reflection. Or code generation tooling that tends to crop up around DI frameworks.

Yes, in general, the ability of IDE to make these kind of large-scale changes quickly, reliably and mostly bug-free is nice. But I rarely miss it in languages where it's impossible.

It may be that one of the ways your language shapes your code is the way you structure it. For instance, in my Lisp codebases, I can hardly think of any place where Java-style automated refactoring could be useful; in the current largish codebase I work on, it rarely is the case that constructs introduced in one file are used directly in more than one or two other files - which makes refactoring entirely doable with a dumb text editor, and Java-like automated refactoring wouldn't save all that much time over doing a regex search and manually visiting every line listed in results.

Re:Generating a Java program with 90% less code by r-w on Thursday December 05, 2019 @02:25PM (#21715510)
What types of program are you writing?
Re:Generating a Java program with 90% less code by philwelch on Friday December 06, 2019 @02:08PM (#21724964)
I would expect that Lisp programming wouldn't derive much benefit from an IDE.
Re:Generating a Java program with 90% less code by addicted44 on Wednesday December 04, 2019 @01:21PM (#21705176)
Unless you're using something like .Net remoting (or the Java equivalent), and now suddenly everything breaks.

Or you have a larger codebase split up into multiple .Net solutions and DLLs where code is referenced through the generated DLLs.

The refactor looks great, until it starts breaking things for the many consumers of your code.

In fact, the latter is a situation where simple text tools will make life a lot safer and easier than whatever the IDE does (which pretty much will be limited to the bounds of the .sln file, whereas a simple text tool operating over files in the entire codebase will alert you to the fact that this is being used elsewhere).

My argument isn't to claim that simple text tools are better at refactoring. They aren't. However, I've run across several situations where we've had issues in a massive codebase because developers believed that refactoring was as easy as hitting the Refactor button in Visual Studio, and everything will work magically.

The belief in programming 'magic' (whether through IDEs or frameworks that abstract a ton) without understanding what those tools actually do is what I'm worried about. Use IDEs to do what you need to by all means, but it's much better when you actually understand what it's doing before doing something with it.

Re:Generating a Java program with 90% less code by philwelch on Wednesday December 04, 2019 @02:54PM (#21706227)
> Or you have a larger codebase split up into multiple .Net solutions and DLLs where code is referenced through the generated DLLs.

Sure--and to be fair, I've never worked in .Net much. But if you're changing the package interface, you should arguably do so in a backwards-compatible fashion anyway, depending on how your stuff actually gets built and deployed. If everything's contained in the same repo and you can't refactor across multiple components in the same repo, that sounds like a problem.

> The belief in programming 'magic' (whether through IDEs or frameworks that abstract a ton) without understanding what those tools actually do is what I'm worried about. Use IDEs to do what you need to by all means, but it's much better when you actually understand what it's doing before doing something with it.

Agreed!

Re:Generating a Java program with 90% less code by arbie on Wednesday December 04, 2019 @12:30PM (#21704425)
What if the IDE did not traverse a specific file during the global search and replace?

Are you relying on a correct and comprehensive project/workspace setup within the IDE?

Re:Generating a Java program with 90% less code by this_user on Wednesday December 04, 2019 @12:52PM (#21704747)
So your argument is that something might, in some extremely rare cases, go wrong, and that is why you'd rather do it the manual way? That's basically like a carpenter refusing to use power tools, because they might, theoretically, explode.
Re:Generating a Java program with 90% less code by Sharlin on Wednesday December 04, 2019 @12:38PM (#21704543)
> Are you relying on a correct and comprehensive project/workspace setup within the IDE?

Of course. Not much point in using an IDE otherwise.

Re:Generating a Java program with 90% less code by philwelch on Wednesday December 04, 2019 @02:55PM (#21706238)
> Are you relying on a correct and comprehensive project/workspace setup within the IDE?

That's not something I "rely" on, it's the first thing I make happen whenever I use an IDE.

Re:Generating a Java program with 90% less code by chosenbreed37 on Wednesday December 04, 2019 @01:21PM (#21705167)
> What if the IDE did not traverse a specific file during the global search and replace?

You generally get compilation/build errors highlighting the bits that were missed (for whatever reason)

Re:Generating a Java program with 90% less code by pavel_lishin on Wednesday December 04, 2019 @12:49PM (#21704702)
Then your tests catch it, and you have to fix a single file manually, instead of a dozen or a hundred or a thousand.
Re:Generating a Java program with 90% less code by ken on Thursday December 05, 2019 @10:03AM (#21712810)
Sure, and that’s exactly the same failure mode as “sed”. What’s the benefit of the big IDE?
Re:Generating a Java program with 90% less code by pavel_lishin on Thursday December 05, 2019 @10:12AM (#21712903)
> What’s the benefit of the big IDE?

To quote myself, "fix a single file manually, instead of a dozen or a hundred or a thousand".

And what happens when you need to rename, say, a method name that's also used as a variable name in many places? xWhat happens if multiple classes define the same method name, but you only want to rename that method for a single class?

Yes, you can probably do it in sed. If you're used to it enough, you can probably do it pretty quick, with sufficient regexps that you only have to debug a few times.

Or you can right click or hit CMD-. or hit F2 or whatever with your cursor on a method name, type in the new name, wait 2 seconds, and you're done.