Skip to content

Handling Breaking Change in libraries #10

@dicko2

Description

@dicko2

Goals

We build libraries to share code. We OpenSource them to share with the community. We InnerSource them to share within our company.

The more people using the shared code the more we will get peer review, contribution, and grow.

Libraries that thrive and survive are ones that are consumer focused not producer focused. If you need to get a company wide mandate from upper management to use your library in the company, there is probably something wrong, I would ask yourself "Why aren't people using it already?" and go ask your potential consumers this question and get feedback and apply it.

Always remember your consumers are engineers. If you don't build what they need, they will simple ignore your code and write it themselves. And by the same token, if you make it hard to upgrade and get changes, they will stop using your code too, and your library will die off.

This is why breaking changes are an important topic.

Idea

There's two types of breaking change we want to talk about

  • Public Contract
  • Functional

First, Avoid breaking changes, Add new contracts with care

Always open an issue, discuss in a meeting and get pier review. Also don't forget to pay attention to English and fluency of the interface names, methods, etc Once Public contracts are in the wild they are hard to change without upsetting people

  1. Open issue
  2. Conduct meeting

Doing a breaking change: Changing or removing Public contracts

Should be planned well ahead.

Recommendations:

  • Obsolete attribute added 12 months ahead, and in the error give an example of which new method is a suitable replacement
  • Only done if absolutely needed, e.g. "I dont like the way the code looks" or "it's not clean" is generally a bad reason
  • Single Major version release with all breaking changes once a year, maybe align with framework updates if your library depends on net framework libraries

Supporting multiple versions?

Leave a branch open at the head of the previous major versions, or tag the release so people can easily patch an old version to fix bugs if they have not been able to upgrade. In general if you do a good job avoiding breaking changes this type of maintenance is not needed or greatly reduced.

How to avoid functional breaking changes?

There is two simple rules to follow that is the best way to ensure you don't have breaking functional changes, but there is no absolute way.

  1. Have good unit test coverage
  2. Never Change unit tests, only add them

You could also employee functional testing, depending on the library this may work as well as unit testing and you can apply the same run, i.e. only add test cases dont change them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions