Make imports private by default

Dan Dan_member at pathlink.com
Fri Apr 14 05:00:24 PDT 2006


>> I never understood why people use private imports .. just what the hell 
>> is the point?
>> Please give real, concrete examples, not just theories/talk.
>> "Clogging up the namespace" doesn't say anything meaningful to me.
>
>It's similar to why things can be made private at class scope.  Private 
>imports are akin to implementation details--a user of the module 
>shouldn't know or care about them.  Public symbols exposed by a module 
>are essentially that module's interface, in much the same was as public 
>symbols of a class are the classes interface.  If it isn't something 
>specifically intended for use then it shouldn't be public.

I've been doing a fair bit of "aspect oriented" programming.  Basically, I'm
taking 100k of code and turning it sideways - instead of the methods, class, and
arrays all in one file I'm putting all the arrays in one file, splitting groups
of methods into separate files, and putting all the 'classes' in a file.

It will make the program dramatically easier to understand and thus maintain.
However, it necessitates exposing many things across modules.  For this purpose,
I'm using private imports to get exactly the files I want.  It's my opinion
though that he's right.  For most cases, you should default your CODE to
private, not the import.





More information about the Digitalmars-d mailing list