Does it make sense – when loading a module – to import needed functions explicitly when the module does export these functions by default and when it is used a object-orientated interface?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think this is subjective, but yes, it often makes sense. Default imports are more convenient, but explicit imports are somewhat safer, in that you’re less likely to accidentally import something without knowing about it.
If a module only has an object-oriented interface, then it shouldn’t export very much by default (since method calls don’t benefit from the method names having been imported). If a module offers both an object-oriented interface and a procedural one, and you’re only using the object-oriented interface, then it’s very likely to be a good idea to specify your imports explicitly, since you’ll need very few imports (or none at all). This depends, of course, on whether the module exports any of its procedural function-names by default.