How to define Composition Roots for libraries (Javascript/inversify)

I’m building a console app (A), which depends on library B. Library B further depends on library C. I am building all 3 entities. Most of the development completed so far has been done using a functional design and so far this is working well, and is currently stateless, and no instantiations have been needed so far. I am now at a point where I need to declare some dependencies and inject them as appropriate. The interaction between libraries B and C should be transparent to the application A. I have been reading up on dependency injection/inversion of control and I’ve decided that I will use inversify as the dependency injection framework. One point I am ‘stuck’ on is the notion of Composition Roots and where they should be created. I found this article ‘’ which states that the CR should be as close to the main entry point of the application. It also says that CRs, are not applicable to libraries just applications. But the interaction between libraries B & C is an implementation detail that the client should not be aware of. So what is the correct resolution to this issue? I’m inclined to define a CR in library B so that its dependency on a component in library C can be injected. This seems correct to me, but it does seem at odds with established wisdom. To quote the article: “Only applications should have Composition Roots. Libraries and frameworks shouldn’t.”. It seems that to do this correctly, the client app needs to be aware of all the implementation crud and its up to the client to compose everything via a Composition Root.

But if library B needs a dependency to be injected into it (which comes from library C), how do we do this? I’m now suffering analysis paralysis …

PS, I also considered this article: Design/Architecture for passing cross-cutting parameters via constructors at composition roots?, but that does not address the issue of the application/client being aware of downstream dependencies.

Statistical tests for modular roots of high complexity integer sequences?

Take two integers $ n$ and $ m$ with $ 0<\log_2m<n<m$ .

Let $ r=(2(n!)+1)\bmod m$ .

Denote the two roots of $ ((2(n!)+1)\bmod m)^2\bmod m$ by $ r_1$ and $ r_2$ .

One of $ r_1$ and $ r_2$ equals $ r$ .

  1. Is there a statistical test that performs better than a random coin toss at finding correct one of $ r_1$ or $ r_2$ ?

  2. Can we replace $ a(n!)+b$ by any other sequence whose complexity is purportedly high while a statistical test can separate them with significance?

Roots of $x^n-x^{n-1}-\cdots-x-1$

It is easy to see that $ f(x)=x^n-x^{n-1}-\cdots-x-1$ has only one positive root $ \alpha$ which lies in the interval $ (1,2)$ . But it is claimed that this root is a Pisot number, i.e., the other roots are in the open $ \{z\in \mathbb{C}: |z|<1\}$ . I have tried the following, but I failed. I considered $ $ P(x)=(1-x)f(x)=x^{n+1}-2x^n+1=x^n(x-2)+1$ $ and then I tried to use Rouche’s theorem, by picking $ g(x)=-x^n(x-2)$ and trying to show that $ 1<|g(z)|+|P(z)|$ for $ |z|=1$ . Proving this implies that $ P(x)$ has $ n$ roots in $ \{z\in \mathbb{C}: |z|<1\}$ which demonstrates the claim. But this inequality fails at $ z=1$ . Can you give me an idea how one can prove this claim?

Read model with data from multiple aggregate roots (different contexts)

I’m curious to how to join data from multiple aggregate roots in an read model for an event sourced aggregate root. Can try to take a simple example:

If I have an aggregate root called Cart which supports following events in it’s event stream (properties in parentheses – keep in mind this is an simple example):

AddProductToCart(cartId: Int, productId: Int) RemoveProductFromCart(cartId: Int, productId: Int) AddUserLicenseToProduct(cartId: Int, productId: Int, userId: Int) RemoveUserLicenseFromProduct(cartId: Int, productId: Int, userId: Int) EmptyCart(cartId: Int) 

It’s ok when projecting read models with data coming from this event stream. I can for example project a cart object which looks something like this:

Cart(cartId: Int, products: List[Product])  Product(productId: Int, userLicenses: List[UserLicense]) UserLicense(userId: Int) 

But how does one join data from another aggregate root in another context into this cart projection. For example if I wanted to extend the read model with data from the Product aggregate root which lives in another context. Let’s say I would like to extend it with productName and productType.

Take into consideration we are working in an distributed system, where Product and Cart would be live in different services/applications.

Taylor’s polynomials and loss of real roots

Real-rootedness, log-concavity, and unimodality are intertwined properties. It’s in this light that I was prompted to ask the question below.

Suppose the roots of a polynomial $ p(x)$ are all real and $ p(0)>0$ . Fix an integer $ k\geq0$ and consider the function $ f=\frac1{p^{2k+1}}$ . I like to consider the partial sums (polynomial) $ $ \sum_{j=0}^{2k}\frac{f^{(j)}(0)}{j!}x^j; \tag1$ $ where $ f^{(j)}$ means the $ j$ -th derivative.

QUESTION. Is it true that the polynomial in (1) has no real roots?

Real Powers of Roots of Unity and Real Linear Combinations of Roots of Unity

Notation: For any integers $ n,k$ , with $ n\neq0$ , I write $ \xi_{n}^{k}$ to denote $ e^{2k\pi i/n}$ .

1) Let $ s\in\mathbb{R}\backslash\mathbb{Q}$ , and let $ n\geq2$ . When, if ever, do there exist $ c_{0},c_{1},\ldots,c_{n-1}\in\mathbb{R}$ so that: $ $ \xi_{n}^{s}=\sum_{k=0}^{n-1}c_{k}\xi_{n}^{k}$ $

2) It is well known that for an odd prime $ p$ , the complex numbers $ \xi_{p},\xi_{p}^{2},\ldots,\xi_{p}^{p-1}$ are linearly independent over $ \mathbb{Q}$ . Are they also linearly independent over $ \mathbb{R}$ ?

3) Let $ s\in\mathbb{R}\backslash\overline{\mathbb{Q}}$ (where $ \overline{\mathbb{Q}}\subseteq\mathbb{C}$ is the set of algebraic numbers), and let $ n\geq2$ . Is anything known about the transcendence of $ \xi_{n}^{s}$ ?