Last update March 7, 2012

Best Practices /
Module Tips



Some tips on using modules

  • I always put a module statement in each source file. The module statement states the module name and the complete package name. For example:
       module ui.core;
  • I always call a module the same name as its source file name.
  • I always have the source files in the correct directory, based on the package name that is in their module statement. (For example, the file above would be called 'core.d', and it would be placed in the 'ui/' directory.)
  • I always give the fully specified path/file to the DMD compiler (via the "build" utility).
  • I always use "private import", though I can see myself relaxing this at odd times, if especially exceptional circumstances came up.
  • I always use fully specified package and module names on the import statements.
When I do all this, I don't have problems.

BTW, the "multiplied defined module" message is very misleading.

Adapted from NG:digitalmars.D/16691 by Derek Parnell


FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: March 7, 2012 19:06 (diff))