|
|
|
|
|
by michaelsalim
1586 days ago
|
|
I'm currently mentoring someone from scratch and they're using autocompletion a lot. Have mixed feelings about it to be honest. I'm not a big fan of tools like Copilot and it'll be really hard for someone to convince me of its value. On one side, it's as you mentioned. If you randomly pick a "solution" and hope that it works, you won't understand why you use that specific solution. And sure enough, many times they'd use autocomplete and get a solution that doesn't really solve the problem. One particular problem I remember was a type difference issue. They had a string and needed to compare it with a string in an object. Easy, just do something like myObj.myVar == "string" right? But autocomplete suggested myObj.equals("string") instead. This is java code. Then I had to explain why it didn't work as intended even though the code compiled. But observing it more, I decided not to stop them from doing it for now. I think it can be useful for learning purposes especially at the start. It's not that great for understanding but it does help them familiarize with all the different syntax and possibilities. At the end of the day, I don't think it's that much different from randomly copying solutions from stack overflow until one works. |
|
Actually, you need to use `.equals()` for value equality on reference types in Java (like Strings). Using `==` will give you reference equality, which is almost never what you want. You probably wanted `myObj.myVar.equals("string")`