Import status

Georg Wrede georg.wrede at nospam.org
Wed Jul 12 13:42:09 PDT 2006



Rioshin an'Harthen wrote:
> "Lucas Goss" <lgoss007 at gmail.com> wrote:
> 
>>Question about prefix-importing...
>>
>>Is this suggested as importing the fully qualified name as well? If so 
>>then I'd change the solution to too wordy, as the current alias already 
>>does this, just on a separate line correct? Which is it:
>>
>>1 -prefix-importing (with fully qualified name)
>>    -tries to solve problem of being too wordy (a one line alias import)
>>
>>2 -prefix-importing (replacing fully qualified name)
>>    -tries to solve problem of name collisions
> 
> 
> My opinion is: never ever forbid the use of FQN's to use a symbol.
> 
> I tend to (in longer functions), if I've imported according to as follows
> 
> import module.with.a.long.name;
> alias module.with.a.long.name mwln;
> 
> to write something akin to
> 
> module.with.a.long.name.foo();
> // a few lines later
> mwln.bar();
> 
> which helps readability - first time a symbol is used from a module, write 
> the FQN of the module name, and after that, use the short alias.
> 
> In Java, I tend to do something like this. I import the symbols I require, 
> and the first time in a longish method, I write the fully qualified name of 
> the symbol, and only then the short form - this lets me, or anyone else 
> reading the code, quickly in the same function/method see from where the 
> symbol comes from, and isn't too much of a trouble when it comes to 
> wordiness. 

Not bad.

Smart people tend to find adequate practices however the law of the land is!



More information about the Digitalmars-d mailing list