Feedback on my first macro-based library - Modulex

Hey folks :wave:

I implemented a library that uses macros extensively, and I’d appreciate feedback from people that are more versed at writing macros in Elixir. The library is application_module and I plan to use it with mocking libraries like Mox or Hammox to remove some boilerplate code and ensure consistency throughout the codebase.

I managed to get it working but it required a lot of try-and-error and through-ChatGPT learning to get it to a functional state so I wouldn’t be surprised if there’s a lot of room for improvement.

Thanks,
Pedro

2 Likes

Don’t “nest” modules under built-in modules. In your case it’s Application. It’s a bad practice and frowned upon when it comes to libraries like plug’s Plug, let alone the built-in Application module. I understand that ApplicationModule might be considered ugly but nodule names are just atoms so it doesn’t really matter.

6 Likes

This is a very good advise. I’ll rename it to ApplicationModule instead. I’m not entirely convinced about the name, but I can keep it until I can find something better. Thanks a lot @krasenyp.

3 Likes