Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Dr. Strangeversion, or,
How I learned to stop
worrying and love
Qualifiers
Neil Bartlett – Paremus Ltd
Everything you always
wanted to know about
versions (*but were
afraid to ask)
OMG I’m doing a talk on
versions(!) and desperately
need to sex up the title
What areVersions FOR
Anyway??
Uniquely identifying
releases
• Great, just use a SHA.
• Done!
• Next speaker please...
Wait, which is “Latest”?
• 21aa486ed420da46ec2c25ea3ac674eb602367ce
• 07e3d4c74bd61e231710461a8b911e4073de8594
• 8090b6376...
Use Integers!
• 1
• 2
• 3
• 4
• Man that was easy. Next?
Compatibility
• Can I run code compiled for version N on
version N+x?
• Naïve answer: yes for all N, x.
• Example: Google ...
Until Things Change
• Hmm we need to make a breaking change.
• How do we signal this?
Version Segments
•1.0.0
•2.10.15-SNAPSHOT
• java full version "1.6.0_26-b03-383"
What Does it MEAN?
• Versions are COMMUNICATION
• A promise to other developers about
compatibility and future changes.
Scope of Changes?
1.6.0_26-b03-383
1.7.0_05-b06
1.7.0_06-b24
OSGiVersions
LegalVersions
0.0.0
1.0.0
2.0.9
3.4.12
4.0.4.beta3
5.1.2.RELEASE
Omitting segments
1.1 == 1.1.0
1 == 1.0 == 1.0.0
<empty> == 0 == 0.0 == 0.0.0
Qualifiers
1.0.0 == 1.0.0.<empty>
1.1.0.beta > 1.1.0.alpha
1.1.0.beta3 > 1.1.0.beta2
GOTCHAS
1.1.0.beta > 1.1.0
1.1.0.beta2 > 1.1.0.beta10
SemanticVersions
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?
Importing
• I compiled against 1.2.14
• Can I use 1.2.15?
• Can I use 1.3.0?
• How about 2.0.0?
Semantics
• Need consistent rules for which segment
to bump
• Based on degree of change in the artifact
Bigger than Java
• Tom Preston-Warner (GitHub co-founder)
• http://semver.org/
OSGi Semantics
• R5 Core Spec section 3.7.3
• SemanticVersioning Technical Whitepaper,
06 May 2010.
• Major: breaking change
• Minor: new feature
• Micro: non-visible change
• Qualifier: no semantic meaning
Is This Breaking?
public interface Foo {
void foo();
}
public interface Foo {
void bar();
}
Is This Breaking?
public interface Foo {
void foo();
}
public interface Foo {
void foo(int x);
}
Is This Breaking?
public interface Foo {
void foo();
}
public interface Foo {
/** Fooify all the Bars
* @author Bob */
voi...
Is This Breaking?
public interface Foo {
void foo();
}
public interface Foo {
void foo();
void bar();
}
Consumer vs Provider
• Consumers can ignore new features
• Providers CANNOT
Consumer Range
• Export: 1.0.0
• Import: [1.0.0 , 2.0.0)
Provider Range
• Export: 1.0.0
• Import: [1.0.0 , 1.1.0)
Consumer-Implements
public interface Callback {
void thingChanged(Thing t);
}
Bang!
public interface Callback {
void thingChanged(Thing t);
void otherThingChanged();
}
Putting it into Practice
Best Practices: USELESS
• “Always version your exported packages”
• Great. I have 1000s of packages!
• (Maybe you should h...
Possible Solution
• “Release Train”: synchronise everything into
one massive release once a year
• It’s The Eclipse WayTM
...
Use The Tools, Luke
• Don’t make developers reason about
import ranges.
• Don’t make developers reason about
export versio...
bnd
• Import-Package used to be such a hassle
• bnd made that problem go away!
• It can make the version problem go away
t...
DEMO
Feature Summary
• Import range generated
• Consumer/provider relation detected
• Export version calculated on release
• Wr...
Help the Tool
to HelpYou
• Version analysis of executable code is
impossible... in practice and in theory
• Another benefit of service-oriented desi...
• Consumers should NOT track latest API
• Use the LOWEST version they can still be
compatible with
• Providers should trac...
Qualifiers
• There will be many versions 1.0.0 before it
is “released”
• Qualifier can be used to signal “phase”
• E.g.ALPHA, BETA, RC...
Problem
1.0.0.RC5
1.0.0.RELEASE
WYTIWYR
• RC5 is thoroughly tested by QA, it passes.
• Replace RC5 with RELEASE and ship it!
• But this change can affect ...
Smart Repositories
• Developer Repo
• Freely replace 1.0.0 with new 1.0.0
• Release Repo
• Attempting to replace 1.0.0 wit...
Conclusion
• Versions are communication
• They describe a fundamental aspect of your
code
• They can be derived, directly and
automat...
Marketing Department:
KeepYour Filthy Hands
Off MyVersions!!!
Tip
• Give the marketing dept their own version:
Bundle-ManifestVersion: 2.0
Bundle-SymbolicName: org.example
Bundle-Versi...
Finally: Like Tools?
• 20:00 Tonight: OSGi Tooling BoF,
Seminarraume 1-3
• Friday all day: OSGi Tooling Workshop,
organise...
Everything You Always Wanted to Know About Versions* (*but were afraid to ask) - Neil Bartlett
Upcoming SlideShare
Loading in …5
×

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

409 views

Published on

OSGi Community Event 2012

Published in: Technology
  • Be the first to comment

  • Be the first to like this

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

  1. 1. Dr. Strangeversion, or, How I learned to stop worrying and love Qualifiers Neil Bartlett – Paremus Ltd
  2. 2. Everything you always wanted to know about versions (*but were afraid to ask)
  3. 3. OMG I’m doing a talk on versions(!) and desperately need to sex up the title
  4. 4. What areVersions FOR Anyway??
  5. 5. Uniquely identifying releases • Great, just use a SHA. • Done! • Next speaker please...
  6. 6. Wait, which is “Latest”? • 21aa486ed420da46ec2c25ea3ac674eb602367ce • 07e3d4c74bd61e231710461a8b911e4073de8594 • 8090b637657d09e1dacea12219ad5fb6d1353f96 • 62529587489ba2fd8a190d2c383738f8291ca9b0 • 92825c17eae8c35341ad0dc05478b7189fd95f4f • 00cfb1b293fe48ac166171fdad9ee7e804d1894f • dc415b82d06d3165e00ec552657b0e387aa368de • f61302d1cb5c1593d65e005104ffc001fddbae7d • ...
  7. 7. Use Integers! • 1 • 2 • 3 • 4 • Man that was easy. Next?
  8. 8. Compatibility • Can I run code compiled for version N on version N+x? • Naïve answer: yes for all N, x. • Example: Google Guava
  9. 9. Until Things Change • Hmm we need to make a breaking change. • How do we signal this?
  10. 10. Version Segments •1.0.0 •2.10.15-SNAPSHOT • java full version "1.6.0_26-b03-383"
  11. 11. What Does it MEAN? • Versions are COMMUNICATION • A promise to other developers about compatibility and future changes.
  12. 12. Scope of Changes? 1.6.0_26-b03-383 1.7.0_05-b06 1.7.0_06-b24
  13. 13. OSGiVersions
  14. 14. LegalVersions 0.0.0 1.0.0 2.0.9 3.4.12 4.0.4.beta3 5.1.2.RELEASE
  15. 15. Omitting segments 1.1 == 1.1.0 1 == 1.0 == 1.0.0 <empty> == 0 == 0.0 == 0.0.0
  16. 16. Qualifiers 1.0.0 == 1.0.0.<empty> 1.1.0.beta > 1.1.0.alpha 1.1.0.beta3 > 1.1.0.beta2
  17. 17. GOTCHAS 1.1.0.beta > 1.1.0 1.1.0.beta2 > 1.1.0.beta10
  18. 18. SemanticVersions
  19. 19. 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?
  20. 20. Importing • I compiled against 1.2.14 • Can I use 1.2.15? • Can I use 1.3.0? • How about 2.0.0?
  21. 21. Semantics • Need consistent rules for which segment to bump • Based on degree of change in the artifact
  22. 22. Bigger than Java • Tom Preston-Warner (GitHub co-founder) • http://semver.org/
  23. 23. OSGi Semantics • R5 Core Spec section 3.7.3 • SemanticVersioning Technical Whitepaper, 06 May 2010.
  24. 24. • Major: breaking change • Minor: new feature • Micro: non-visible change • Qualifier: no semantic meaning
  25. 25. Is This Breaking? public interface Foo { void foo(); } public interface Foo { void bar(); }
  26. 26. Is This Breaking? public interface Foo { void foo(); } public interface Foo { void foo(int x); }
  27. 27. Is This Breaking? public interface Foo { void foo(); } public interface Foo { /** Fooify all the Bars * @author Bob */ void foo(); }
  28. 28. Is This Breaking? public interface Foo { void foo(); } public interface Foo { void foo(); void bar(); }
  29. 29. Consumer vs Provider • Consumers can ignore new features • Providers CANNOT
  30. 30. Consumer Range • Export: 1.0.0 • Import: [1.0.0 , 2.0.0)
  31. 31. Provider Range • Export: 1.0.0 • Import: [1.0.0 , 1.1.0)
  32. 32. Consumer-Implements public interface Callback { void thingChanged(Thing t); }
  33. 33. Bang! public interface Callback { void thingChanged(Thing t); void otherThingChanged(); }
  34. 34. Putting it into Practice
  35. 35. Best Practices: USELESS • “Always version your exported packages” • Great. I have 1000s of packages! • (Maybe you should have far fewer exported packages)
  36. 36. Possible Solution • “Release Train”: synchronise everything into one massive release once a year • It’s The Eclipse WayTM • Also the Google way & many others
  37. 37. 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!
  38. 38. bnd • Import-Package used to be such a hassle • bnd made that problem go away! • It can make the version problem go away too.
  39. 39. DEMO
  40. 40. Feature Summary • Import range generated • Consumer/provider relation detected • Export version calculated on release • Wrong version => broken build
  41. 41. Help the Tool to HelpYou
  42. 42. • Version analysis of executable code is impossible... in practice and in theory • Another benefit of service-oriented design • Focus on the interface • Minimise exports
  43. 43. • Consumers should NOT track latest API • Use the LOWEST version they can still be compatible with • Providers should track: more tightly coupled.
  44. 44. Qualifiers
  45. 45. • 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
  46. 46. Problem 1.0.0.RC5 1.0.0.RELEASE
  47. 47. 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. • WhatYou Test Is WhatYou Release.
  48. 48. 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?
  49. 49. Conclusion
  50. 50. • Versions are communication • They describe a fundamental aspect of your code • They can be derived, directly and automatically, from your code
  51. 51. Marketing Department: KeepYour Filthy Hands Off MyVersions!!!
  52. 52. Tip • Give the marketing dept their own version: Bundle-ManifestVersion: 2.0 Bundle-SymbolicName: org.example Bundle-Version: 2.1.14.20121024_1400 Bundle-Activator: org.example... Initech-Version: 12.0 Super Enhanced XP Ultimate Edition (Manatee) Export-Package: org.example;version=1
  53. 53. 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

×