Knigge - An opinionated approach to behaviours

Knigge was born out of a desire to standardize dealing with behaviours and their implementations.

As great fans of mox we longed for an easy way to swap out implementations from the configuration which lead us to introduce a facade pattern, where a module’s sole responsibility was loading the correct implementation and delegating calls.

This pattern turned out to be very flexible and useful but required a fair bit of boilerplate code. Knigge was born out of an attempt to reduce this boilerplate to the absolute minimum.

You can read about our motivation in depth in our devblog.

6 Likes

Thanks for sharing and I already considered using Knigge, before I found a simple solution to avoid the boilerplate of behaviors and implementation details. Currently I leverage on Module.spec_to_callback/2, which is in my use-case good enough.

Along the lines I implemented it like this: https://gist.github.com/jhattwich/6f7acbaaa3cd2f9cdbf2afe8c13328f0

4 Likes

@0x6a68 Looks like the gist link no longer exists. I’d be much interested if you could publish it again!

1 Like

Sure. https://gist.github.com/0x6a68/6f7acbaaa3cd2f9cdbf2afe8c13328f0

3 Likes

v1.4.0 - 2020-03-26

Added

  • #18: Add default option to use Knigge
  • #22: Ease contributing by adding a CONTRIBUTING guide and a PULL_REQUEST_TEMPLATE

Changed

  • #19: Fix handling of callbacks without brackets
1 Like