Top Banner
Dr. Strangeversion, or, How I learned to stop worrying and love Qualifiers Neil Bartlett – Paremus Ltd
54

Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Aug 19, 2015

Download

Technology

mfrancis
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Dr. Strangeversion, or,How I learned to stop

worrying and love Qualifiers

Neil Bartlett – Paremus Ltd

Page 2: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Everything you always wanted to know about

versions (*but were afraid to ask)

Page 3: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

OMG I’m doing a talk on versions(!) and desperately need to sex up the title

Page 4: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

What are Versions FOR Anyway??

Page 5: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Uniquely identifying releases

• Great, just use a SHA.

• Done!

• Next speaker please...

Page 6: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Wait, which is “Latest”?

• 21aa486ed420da46ec2c25ea3ac674eb602367ce• 07e3d4c74bd61e231710461a8b911e4073de8594• 8090b637657d09e1dacea12219ad5fb6d1353f96• 62529587489ba2fd8a190d2c383738f8291ca9b0• 92825c17eae8c35341ad0dc05478b7189fd95f4f• 00cfb1b293fe48ac166171fdad9ee7e804d1894f• dc415b82d06d3165e00ec552657b0e387aa368de• f61302d1cb5c1593d65e005104ffc001fddbae7d• ...

Page 7: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Use Integers!

• 1

• 2

• 3

• 4

• Man that was easy. Next?

Page 8: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Compatibility

• Can I run code compiled for version N on version N+x?

• Naïve answer: yes for all N, x.

• Example: Google Guava

Page 9: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Until Things Change

• Hmm we need to make a breaking change.

• How do we signal this?

Page 10: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Version Segments

•1.0.0

•2.10.15-SNAPSHOT

• java full version "1.6.0_26-b03-383"

Page 11: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

What Does it MEAN?

• Versions are COMMUNICATION

• A promise to other developers about compatibility and future changes.

Page 12: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Scope of Changes?

1.6.0_26-b03-383

1.7.0_05-b06

1.7.0_06-b24

Page 13: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett
Page 14: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

OSGi Versions

Page 15: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Legal Versions0.0.01.0.02.0.93.4.124.0.4.beta35.1.2.RELEASE

Page 16: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Omitting segments

1.1 == 1.1.0 1 == 1.0 == 1.0.0<empty> == 0 == 0.0 == 0.0.0

Page 17: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Qualifiers

1.0.0 == 1.0.0.<empty>

1.1.0.beta > 1.1.0.alpha1.1.0.beta3 > 1.1.0.beta2

Page 18: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

GOTCHAS

1.1.0.beta > 1.1.01.1.0.beta2 > 1.1.0.beta10

Page 19: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Semantic Versions

Page 20: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Which Segment?

• I made a change to 1.2.14

• Is my new version 1.2.15?

• Or 1.3.0?

• Or 2.0.0?

Page 21: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Importing

• I compiled against 1.2.14

• Can I use 1.2.15?

• Can I use 1.3.0?

• How about 2.0.0?

Page 22: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Semantics

• Need consistent rules for which segment to bump

• Based on degree of change in the artifact

Page 23: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Bigger than Java

• Tom Preston-Warner (GitHub co-founder)

• http://semver.org/

Page 24: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

OSGi Semantics

• R5 Core Spec section 3.7.3

• Semantic Versioning Technical Whitepaper, 06 May 2010.

Page 25: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

• Major: breaking change

• Minor: new feature

• Micro: non-visible change

• Qualifier: no semantic meaning

Page 26: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Is This Breaking?public interface Foo {

void foo();}

public interface Foo {void bar();

}

Page 27: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Is This Breaking?public interface Foo {

void foo();}

public interface Foo {void foo(int x);

}

Page 28: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Is This Breaking?public interface Foo {

void foo();}

public interface Foo {/** Fooify all the Bars

* @author Bob */void foo();

}

Page 29: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Is This Breaking?public interface Foo {

void foo();}

public interface Foo {void foo();void bar();

}

Page 30: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Consumer vs Provider

• Consumers can ignore new features

• Providers CANNOT

Page 31: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Consumer Range

• Export: 1.0.0

• Import: [1.0.0 , 2.0.0)

Page 32: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Provider Range

• Export: 1.0.0

• Import: [1.0.0 , 1.1.0)

Page 33: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Consumer-Implements

public interface Callback {void thingChanged(Thing t);

}

Page 34: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Bang!

public interface Callback {void thingChanged(Thing t);void otherThingChanged();

}

Page 35: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Putting it into Practice

Page 36: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Best Practices: USELESS

• “Always version your exported packages”

• Great. I have 1000s of packages!

• (Maybe you should have far fewer exported packages)

Page 37: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Possible Solution

• “Release Train”: synchronise everything into one massive release once a year

• It’s The Eclipse WayTM

• Also the Google way & many others

Page 38: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Use The Tools, Luke• Don’t make developers reason about

import ranges.

• Don’t make developers reason about export versions.

• WE WILL GET IT WRONG

• We’re only human!

Page 39: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

bnd

• Import-Package used to be such a hassle

• bnd made that problem go away!

• It can make the version problem go away too.

Page 40: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

DEMO

Page 41: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Feature Summary

• Import range generated

• Consumer/provider relation detected

• Export version calculated on release

• Wrong version => broken build

Page 42: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Help the Toolto Help You

Page 43: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

• Version analysis of executable code is impossible... in practice and in theory

• Another benefit of service-oriented design

• Focus on the interface

• Minimise exports

Page 44: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

• Consumers should NOT track latest API

• Use the LOWEST version they can still be compatible with

• Providers should track: more tightly coupled.

Page 45: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Qualifiers

Page 46: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

• There will be many versions 1.0.0 before it is “released”

• Qualifier can be used to signal “phase”

• E.g. ALPHA, BETA, RC1, SNAPSHOT, RELEASE

Page 47: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Problem

1.0.0.RC5

1.0.0.RELEASE

Page 48: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

WYTIWYR• RC5 is thoroughly tested by QA, it passes.

• Replace RC5 with RELEASE and ship it!

• But this change can affect resolution, and other changes can creep in.

• What You Test Is What You Release.

Page 49: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Smart Repositories• Developer Repo

• Freely replace 1.0.0 with new 1.0.0

• Release Repo

• Attempting to replace 1.0.0 with another 1.0.0 is an error that breaks the build

• Multi-level Repos: dev, group, division, organisation... global?

Page 50: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Conclusion

Page 51: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

• Versions are communication

• They describe a fundamental aspect of your code

• They can be derived, directly and automatically, from your code

Page 52: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Marketing Department:Keep Your Filthy Hands

Off My Versions!!!

Page 53: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Tip• Give the marketing dept their own version:

Bundle-ManifestVersion: 2.0Bundle-SymbolicName: org.exampleBundle-Version: 2.1.14.20121024_1400Bundle-Activator: org.example...Initech-Version: 12.0 Super Enhanced XP Ultimate Edition (Manatee)Export-Package: org.example;version=1

Page 54: Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett

Finally: Like Tools?

• 20:00 Tonight: OSGi Tooling BoF, Seminarraume 1-3

• Friday all day: OSGi Tooling Workshop, organised by User Forum Germany

• http://germany.osgiusers.org/Main/OSGiToolingWorkshop