2

According to the Stable Dependencies Principle, the dependency

should be in the direction of the stability

But:

if you don't know what types of changes are likely, it is best to wait and see what happens as the system evolves.

Now:

Say I'm designing a blog, I am tempted to think the stability ranking is:

  1. Comment - less likely to change
  2. Post
  3. User - more likely to change (because it's bigger?)

If I let Comment depend on Post, then Comment will change more likely. But also vice-versa, if I let Post depend on Comment, Post will change more likely, correct?

This wants to be a general argument, every app has a hierarchy similar to users, a main object and children.

Where is my best bet for change? higher level classes or lower level? And why?

5

It's not about what is most likely to change, it's the difficulty of changing it.

The document you linked actually explains it quite well:

"Stable" roughly means "hard to change", whereas "instable" means "easy to change".

The concept can be better thought of as layers of software, it might be easy to change a UI, but much more difficult to change the API it calls, and even more difficult to change the DB that it is built upon. The DB is the stable part there.

For other systems, it might be really difficult to change the UI (e.g. a desktop app rolled out to 10,000 remote users) in which case it becomes the most stable.

  • So it's not really about classes / models? Can we make a relation / parallelism? – ecoologic Jul 23 '15 at 13:15
  • 2
    @ecoologic The principle can apply on the level of individual classes, but it's truest at the architectural level. What do you mean by "relation/parallelism"? – Ixrec Jul 23 '15 at 13:19
0

I found some good help on this talk from Sandi Metz, one of my idols, Less the path to better design.

At 16:05 the Stable Dependencies Principle comes up in the context I am interested in, class design. Her point is "you can't know", so embrace uncertainty. It's a great talk.

So I went on and checked the churns of some of the apps I currently maintain and it seems the order is the one given in my question.

However, that might be the way we are used to manage direction, for good or bad. Inverting the direction will likely produce the opposite effects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.