Use of (non) qualified names

Posted by AProgrammer on Stack Overflow See other posts from Stack Overflow or by AProgrammer
Published on 2010-04-29T16:47:55Z Indexed on 2010/04/29 16:57 UTC
Read the original article Hit count: 322

If I want to use the name baz defined in package foo|bar|quz, I've several choices:

  1. provide fbq as a short name for foo|bar|quz and use fbq|baz
    • use foo|bar|quz|baz
    • import baz from foo|bar|quz|baz and then use baz (or an alias given in the import process)
    • import all public symbols from foo|bar|quz|baz and then use baz

For the languages I know, my perception is that the best practice is to use the first two ways (I'll use one or the other depending on the specific package full name and the number of symbols I need from it). I'd use the third only in a language which doesn't provide the first and hunt for supporting tools to write the import statements. And in my opinion the fourth should be reserved to package designed with than import in mind, for instance if all exported symbols start with a prefix or contains the name of the package.

My questions:

  • what is in your opinion the best practice for your favorite languages?
  • what would you suggest in a new language?
  • what would you suggest in an old language adding such a feature?

© Stack Overflow or respective owner

Related posts about best-practices

Related posts about language-agnostic