Should I prefix package names with the name of my program?

Johannes Loher johannesloher at fg4f.de
Tue Jan 29 22:51:15 UTC 2019


Am 28.01.19 um 18:29 schrieb H. S. Teoh:
> On Mon, Jan 28, 2019 at 04:59:22PM +0000, Victor Porton via Digitalmars-d-learn wrote:
>> Should I prefix all module names with `xmlboiler.` (where XML Boiler
>> is the name of my program). These packages are expected to be used
>> internally by my program, not as an exported API (however there are
>> some little chances that in the future I will make a public API)
> 
> I won't pretend to speak for anyone else, but personally, I don't even
> bother with packages until my code has grown past a certain size. It's
> just useless cruft and needless complexity for small to medium sized
> projects. It's only when you're planning to export a public API, or when
> your code has grown past a certain size, that it becomes useful to
> segregate the code into different packages.
> 
> So IMO you don't need to bother.  You can always refactor the code later
> to have a package name when you make a public API.
> 
> 
> T
> 

This is basically the same thing I do: Start with toplevel modules and
reorder them into packages once things get more complicated. Mostly I
only include a top level package named like my project when writing a
project which might be used by other projects (i.e. library code). So
far this has worked very well for me.

If you expect name clashes with other modules you import, prefixing your
own modules with a top level package is a valid solution.


More information about the Digitalmars-d-learn mailing list