6 ms·
I sometimes wonder if IDE users realize you can do 99.9% of the same things with simple tools. Personally I don't want my editor magically updating the codebas
by toolz 7y ago
I sometimes wonder if IDE users realize you can do 99.9% of the same things with simple tools. Personally I don't want my editor magically updating the codebase because there will be edge cases and I don't want magic happening in the background when those edge cases arise. In practice I'm sure the class name change has likely not given you issues in a long time or maybe ever, but that doesn't mean edge cases don't exist and when they happen to someone it can be at the worst times and add significant troubleshooting to an unrelated problem.
edit: further learning those simple tools has a more generic application to other problems while the IDE magic will likely go until there's an issue to be understood and you're depriving yourself of learning generally applicable tooling to trade a slight inconvenience for magic that has the potential to cause great inconvenience and once that magic from the IDE bites you and you learn how it works - you've learned something with no general application to other problems.
edit2: since I can't reply in-line
jcelerier - I _could_ do that with CLI tooling and depending on the language it would be trivial. However, I would _never_ do that because changing the method/function name to suit my context would be very unlikely to avoid making other code less readable. That's a huge anti-pattern that your IDE is making easy.
Further, consider the implications for language design when making language design decisions that require a specific type of IDE magic to be considered a reasonable language design decision. I have a hard time believing relying on the IDE lock-in is good for the community of that language.
philwelch - I genuinely don't know the answer, but what happens when you change a class name -> forget you do it before saving the file -> go to another file and try to change the class name there but have a typo -> go back to the original file and save the change?
I would bet the typo'd change goes unchanged and now you're left scratching your head since that magic has always worked before.
- tsss 7y agoObviously you don't have much experience with IDEs and statically typed languages, which is a shame because they make our life so much easier. There are no edge cases. And even if there were the IDE can show you the refactoring and you can decide on a case-by-case basis. > what happens when you change a class name -> forget you do it before saving the file -> go to another file and try to change the class name there but have a typo -> go back to the original file and save the change? A good IDE does not care if you save the file or not. It is always up-to-date. Renaming a class in just one file is also impossible, since the IDE will do refactorings atomically over the whole project. But lets just assume you somehow managed to fuck it up that badly (things can always go wrong): You will still realize your error almost instantly because a statically typed language does not defer such checks to runtime. The program wouldn't even run anymore. By far the biggest issue with automatic refactoring is accidentally renaming stuff in comments (or forgetting to do so) because I'm too lazy to look at every single place. But find&replace has the same problems.
- philwelch 7y agoWith 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.
- arbie 7y agoWhat 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?
- pavel_lishin 7y agoThen your tests catch it, and you have to fix a single file manually, instead of a dozen or a hundred or a thousand.
- ken 7y agoSure, and that’s exactly the same failure mode as “sed”. What’s the benefit of the big IDE?
- pavel_lishin 7y ago> 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.
- this_user 7y agoSo 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.
- jcelerier 7y ago> I sometimes wonder if IDE users realize you can do 99.9% of the same things with simple tools I'd really like you to show me how you can refactor e.g. a method called "write" in a 500+kloc codebase in less than 5 seconds with "simple tools". With any C++ ide from the last decade it's basically a keyboard shortcut + typing the new name + fixing the few remaining compilation errors that may have cropped up in generic code. With sed & al ? good luck, see you in a few weeks.
- jstimpfle 7y ago> I'd really like you to show me how you can refactor e.g. a method called "write" I'm not taking sides on the issue discussed here, but regarding this quote... This is one of the biggest reasons I don't do OOP. Using plain functions with slightly longer but globally unique names so many issues go away. And the biggest issue is that I can't read a code base if so many function names are not unique and possibly not conveying enough information for local understanding. That style always requires the reader to carry so much context in their head, to be able to resolve the "polymorphism" to concrete implementations. (Yes, in a proper IDE we can jump to the implementation interactively with a few keypresses, but it's still much harder to read).
- pjmlp 7y ago> Using plain functions with slightly longer but globally unique names so many issues go away. Only on monolith code bases without any signs of modularity.
- deleted 7y ago[deleted]
- deleted 7y ago[deleted]
- gmueckl 7y agoGiven the truly excellent quality of refactoring toolsets like Resharper for C# I'd wager that you're more likely to miss an edge case with your manual approach than with the tools. The tools can reliably differentiate between methods of the same name in different classes at the call sites (or between different classes with the same name in different namespaces). They will search comments and strings for occurrences of the name in question and prompt you with a nicely formatted overview dialog box which ones to adjust. The tools are at a point where I'm usually breaking my code when I'm doing manual refactoring, but never when I let the tools do the job.
- nec4b 7y agoIDEs are not magical. They understand your code because they use compilers to parse it, therefore they can also reason about it at a higher level than a simple text editor or CLI tool which treat your code as nothing but characters.