How do you order your Modules?

When you have your models, how do you order all these things:

  • use
  • require
  • alias
  • @attrs

And anything else that goes at the top?

I try to use this ordering:

  1. @moduledoc
  2. @behaviour
  3. use
  4. import
  5. alias
  6. require
  7. defstruct
  8. @type
  9. @module_attribute
  10. @callback
  11. @macrocallback
  12. @optional_callbacks

From @christopheradams’s style guide:

Although I may put @behaviour after use

7 Likes

Thats amazing, thank you!

1 Like