Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Application Version Management

Application Version Management

Keishin Yokomaku

November 25, 2014
Tweet

More Decks by Keishin Yokomaku

Other Decks in Technology

Transcript

  1. Version Management @KeithYokoma - Drivemode, Inc. potatotips #11

  2. KeithYokoma Keishin Yokomaku Drivemode, Inc. Android Engineer GitHub: https://github.com/KeithYokoma e-Book:

    http://amzn.to/1mZNydv
  3. When your application is updated…

  4. You may… • Change database scheme • Write new preferences

    • Migrate to new data models • Trigger data synchronization • and so on…
  5. It could happen! int current = // get current version

    code from PackageManager int previous = // read previous version from Preference if (current <= previous) { return; } if (previous < 1) {} // do when the app is updated from 0 if (previous < 2) {} // do when the app is updated from 0 or 1 if (previous < 3) {} // do when the app is updated from 0 ~ 2 if (previous < 4) {} if (previous < 5) {} if (previous < 6) {}
  6. It could happen! int current = // get current version

    code from PackageManager int previous = // read previous version from Preference if (current <= previous) { return; } if (previous < 1) {} // do when the app is updated from 0 if (previous < 2) {} // do when the app is updated from 0 or 1 if (previous < 3) {} // do when the app is updated from 0 ~ 2 if (previous < 4) {} if (previous < 5) {} if (previous < 6) {}
  7. Too many “if” statement! int current = // get current

    version code from PackageManager int previous = // read previous version from Preference if (current <= previous) { return; } if (previous < 1) {} // do when the app is updated from 0 if (previous < 2) {} // do when the app is updated from 0 or 1 if (previous < 3) {} // do when the app is updated from 0 ~ 2 if (previous < 4) {} if (previous < 5) {} if (previous < 6) {}
  8. Just fit for you https://github.com/KeithYokoma/Fit

  9. Fit • Annotation based • Automatically call your procedure •

    Reusable method declaration • No more dull “if” statement
  10. Version Module class public class MyModule implements VersionModule { //

    foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  11. Version Module class public class MyModule implements VersionModule { //

    foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  12. Version Module class public class MyModule implements VersionModule { //

    foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  13. Application class public class MyApplication extends Application { @Override public

    void onCreate() { super.onCreate(); Fit.initialize(this, new MyModule()); Fit.getInstance().execute(); } }
  14. Application class public class MyApplication extends Application { @Override public

    void onCreate() { super.onCreate(); Fit.initialize(this, new MyModule()); Fit.getInstance().execute(); } }
  15. Application class public class MyApplication extends Application { @Override public

    void onCreate() { super.onCreate(); Fit.initialize(this, new MyModule()); Fit.getInstance().execute(); } }
  16. That’s it!

  17. Behaviour Version 1 to 4 public class MyModule implements VersionModule

    { // foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  18. Behaviour Version 1 to 4 public class MyModule implements VersionModule

    { // foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  19. Behaviour Version 1 to 4 public class MyModule implements VersionModule

    { // foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  20. Behaviour Version 1 to 4 public class MyModule implements VersionModule

    { // foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  21. Behaviour Version 1 to 4 public class MyModule implements VersionModule

    { // foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  22. Behaviour Version 3 to 4 public class MyModule implements VersionModule

    { // foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  23. Behaviour Version 3 to 4 public class MyModule implements VersionModule

    { // foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  24. Behaviour Version 3 to 4 public class MyModule implements VersionModule

    { // foo() is called when the app is updated to // version code = 1, 2 and 3 @VersionCode({1, 2, 3}) public void foo() {} // bar() is called when the app is updated to version code = 4 @VersionCode(4) public void bar() {} }
  25. Version Management @KeithYokoma - Drivemode, Inc. potatotips #11