Diogenes vs Diesis - sithmel/diesis GitHub Wiki

It doesn't happen every day, to be the author of 2 competing libraries. There were some annoying problems in Diogenes I wasn't able to solve without a radical re-design. The result of all these thoughts is Diesis. Diesis is able to do all the useful things that Diogenes was doing, but in a much simpler way. In this document I want to explain some differences.

Services are now dependencies

"Service" is a very generic term, and can create false expectations. I took into consideration many alternatives for what is in essence a vertex of a graph of functions: node, vertex, component etc. The winner was "dependency".

No registry

The main abstraction in Diogenes is the registry. The registry was acting as a collector of services. Diesis has no centralised registry. Every dependency has its own partial view of the graph, limited to its dependencies.

cons

  • getting the adjacency list of all graph is not possible. Dependencies know only a part of the graph. Therefore something like diogenes-lantern is no longer possible

pros

  • injecting local variables in the graph required cloning the registry. It was unwieldy
  • no need to create an "init" function to initialise services in different files/packages

Function references instead of names

cons

  • dependencies have no names, another nail to diogenes-lantern coffin
  • dependencies needs to be injected in the right order

pros

  • you can explore the system using the usual tooling (the editor), instead of diogenes-lantern
  • no chance of circular dependencies, you will incur in the node circular dependency issue before

Dependencies use positional arguments

This is a direct consequence of not using names for dependencies. I usual hate having functions with a long list of arguments. Better passing an object and use destructuring. That makes easier for the caller, not making mistakes in the order of arguments. This is the reason why I went for object destructuring in Diogenes. I realised this is not an issue for Diesis, as you don't have to call the dependencies manually.