Funx library

I am reading Advanced Functional Programming with Elixir.

The book shows how to use various techniques from Haskell in Elixir. Rather than build the library as you go the author has released the full version as https://hex.pm/packages/funx

Eq – Chapter 2 This is about Identity

Ord – Chapter 3 This is about sorting

Monoid – Chapter 4 This is about collecting things

Predicates – Chapter 5 – This is about boolean logic

AI and Clickops

It seems that all of the AI tools seem to have embraced clickops as a configuration method.

Clickops is the practice of using manual entry and configuration of a system. This contrasts with the infrastructure as code approach which is now the main case for traditional development.

Clickops makes having distinct production and staging environments difficult to maintain. How can you know what you had in place at a given time and restore it.

This is especially difficult for secret management. You eventually have to manually configure all the required secrets. This will prevent automatic expiry and renewal (or risk outages).

It might be worth trying to build desired state configuration tools with whatever APIs you do have.

ex_coveralls and Refactoring

Recently I have been working on a new service. It has a single rest endpoint that triggers some work.

The tests for this use Hammox to mock out the external services that it talks to. This ensures that the tests always match the declared typespecs for the services.

This week I added ex_coveralls to the project to see how complete the test coverage was. It revealled several parts of the code that had missing tests. Adding those revealled a few small bugs (one of which had been found in production while I was writing the tests!).

The test coverage was approaching 100% in the main processing area. Combined with a suite of tests that produced all of the possible output states I was confident about performing some refactoring.

The refactors were to replace some tuples with structs and them to remove some pointless wrapping error tuples. Coveralls helped to reveal dead code paths that once removed achieved the 100% coverage.

The tests also helped when working out what could be changed. By adding a log statement at a key points I could see all possible inputs to a function. This helped in finding what to change when adapting.

Now I have simpler code that with the tests I have confidence in.