[英]Why not use all imports?
I understand that I can import packages and get access to lots of already coded classes that I can use to make my programs. 我知道我可以导入包并访问许多已经编码的类,我可以使用它来制作我的程序。 But if they give you access to so many different features, why not just import them all?
但是,如果它们允许您访问许多不同的功能,为什么不直接导入它们呢? I understand that there are thousands of imports and I know it is uncommon to do so (I don't know of anyone that does it but maybe i'm wrong) but why don't people just import them all?
我知道有成千上万的进口产品,我知道这样做是不常见的(我不知道有谁这样做,但也许我错了)但是为什么人们不只是将它们全部导入? Would it make the program too slow?
它会让程序太慢吗? Or just be inefficient?
或者效率低下? I'm just curious.
我只是好奇。 Thanks.
谢谢。
There's a few reasons besides speed I can think of: 除了我能想到的速度之外还有几个原因:
Importing all packages will; 导入所有包将;
where this list can be extended. 这个清单可以扩展到哪里。
It makes your code unreadable because the person who is reading doesn't see your intentions.ALWAYS REMEMBER: "code is written once, twice maybe more, but hundreds of times read by someone. Example: 它使您的代码无法读取,因为正在阅读的人看不到您的意图。请记住:“代码写入一次,两次可能更多,但数百次由某人读取。示例:
In Android SDK there are classes that has the same name but they come from different packages. 在Android SDK中,有些名称相同的类,但它们来自不同的包。 I think that was GPS location manager or something.
我认为这是GPS定位经理或其他什么。 Whatever...other programmer could have difficulties, because he needs to think or manually check which import are you using.
无论如何......其他程序员可能会遇到困难,因为他需要思考或手动检查您使用的是哪个导入程序。
I'm not a advanced programmer but I surmise that the output program might be bigger in size. 我不是一个高级程序员,但我猜测输出程序的大小可能会更大。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.