Writing Modular Programs
Elixirs module system allows us to define layers of related functions. In this part of the course, we'll explore the concepts of modules, and the ability to reference code in one module from another.
Writing Modular ProgramsModules & Three Important Directives
Modules are just a group of several functions, some of which may be private and some of which may be public. Modules give us the ability to define named functions using the
defmacro, which offer a few other features that were unavailable in the world of anonymous functions
Writing Modular ProgramsEXERCISE: Mission Control
We've got a set of tests for a couple of Elixir modules that are used to control a space ship. Alter the code to make the unit tests pass, and ensure that you've kept as much of each module's internal functionality private as possible.
Writing Modular ProgramsBasic Metaprogramming
usemacro is not strictly a directive, it's of particular importance when considering "mixins" for common functionaliy across multiple modules.
Writing Modular ProgramsEXERCISE: Extending a module
usemacro can essentially be used to decorate a module with some code from another