Search code examples
javac#architecturedependenciesdesign-principles

Acyclic Dependency Principle - How could component dependency cycles be reason for "morning-after syndrome"?


I am reading "Agile Principles, Patterns, and Practices in C#" by Robert Martin. And currently I am reading about Acyclic Dependency Principle(ADP). And I cant udnerstand one part in that section. Let me explain the part in a short.

Firstly author gives us the definition of "morning-after syndrome".

Have you ever worked all day, gotten some stuff working, and then gone home, only to arrive the next morning to find that your stuff no longer works? Why doesn't it work? Because somebody stayed later than you and changed something you depend on! I call this "the morning-after syndrome."

Then he explains how to solve the problem:

The solution to this problem is to partition the development environment into releasable components. The components become units of work that can be the responsibility of a developer or a team of developers. When developers get a component working, they release it for use by the other developers. They give it a release number, and move it into a directory for other teams to use, and continue to modify their component in their own private areas. Everyone else uses the released version. As new releases of a component are made, other teams can decide whether to immediately adopt the new release. If they decide not to, they simply continue using the old release. Once they decide that they are ready, they begin to use the new release.

Then he shows us an example for component structure which has not any depdendancy cycle:

What isimportant is the dependency structure of the components. Note that this structure is a directed graph. The components are the nodes, and the dependency relationships are the directed edges.

enter image description here

And then let us say that a new requirement forces us to change one of the classes in MyDialogs such that it makes use of a class in MyApplication. As you can guess, it creates dependancy cycle:

enter image description here

And then he notes that:

The cycle forces MyApplication, MyTasks, and MyDialogs to always be released at the same time.

My question is that: Why? If we are using releasable components, why other two components must be released at the same time with MyDialogs?

Thanks in advance.


Solution

  • "The cycle forces ... to always be released at the same time" is not actually true.

    But the cyclic dependency means that you can make simultaneous changes to MyApplication and MyDialogs that depend on each other, and then you will have to release them at the same time.

    If you ensure that your component dependencies are acyclic, then you are never forced to release both at the same time.

    Also, if there is a dependency cycle in the first release of the components, then you will have to release them all at the same time initially.