How not to layer libraries

One design mistake I have seen with developer attempts to ‘limit’ dependencies is using a pattern like incorporating a callback to a library which they don’t wish to make a “dependency” of another library.

For example in Iguana X there was a library called TRNC which had the core runtime objects for defining components. But this library also had the code to stop and start these components which meant that it needed to have the dependencies required to run Lua instances.

So a solution was made where there was a library created which had callbacks into the Lua library (called BLUA in this instance). This made the linkages of the code more opaque.

A better solution was to shift the concern of the object model out of the TRNC library into a smaller library - which in this case we called CFG.

This allowed unit tests and other code to be written to use the CFG library and the dependencies of the TRNC library to the BLUA library to be straightforward and explicit.