3 ms·
I think this is a matter of the way an individual person writes code, and not something that can be generalized by saying "this is never useful" or "this is alw
by jlarocco 13y ago
I think this is a matter of the way an individual person writes code, and not something that can be generalized by saying "this is never useful" or "this is always useful". Some people will find it annoying, others not.
I personally find it annoying because I compile often. In my workflow I write code for a few minutes then compile it and run some quick tests or even run it through the debugger to make sure everything is working the way I expect. If everything checks out I start on the next bit. I may be adding a feature that I know in advance will use libraries xxx, yyy, and zzz. The natural thing to do is to add those imports when I open the source files that will use them, then get to work implementing the feature.
Another useful reason is to import a library just to make sure it's installed correctly, before writing the code that uses it, although that's less common.