[Mateusz Herych] Guava beyond Collections

[Mateusz Herych] Guava beyond Collections

Presentation from GDG DevFest - the biggest Google related event in Ukraine. October 24-25, Lviv. Learn more at http://devfest.gdg.org.ua/

3a6de6bc902de7f75c0e753b3202ed52?s=128

Google Developers Group Lviv

October 25, 2014
Tweet

Transcript

  1. None
  2. Java is not perfect.

  3. Actually

  4. Java sucks.

  5. Java sucks. At least compared to other languages.

  6. Scala?

  7. Scala? case class Person (firstName: String, lastName: String)

  8. None
  9. class Person { private final String firstName; private final String

    lastName; public Person(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } }
  10. class Person { private final String firstName; private final String

    lastName; public Person(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } }
  11. None
  12. None
  13. Scala? case class Person (firstName: String, lastName: String)

  14. None
  15. None
  16. None
  17. Mateusz Herych GDG Kraków Android GDE Engineer, Base CRM

  18. Guava

  19. Google’s Java

  20. None
  21. None
  22. None
  23. None
  24. null

  25. Wikipedia

  26. Wikipedia In programming, nullable types are a feature of the

    type system of some programming languages which allow the value to be set to the special value NULL instead of the usual possible values of the data type. In statically-typed languages, a nullable type is an option type (in functional programming terms), while in dynamically-typed languages (where values have types, but variables do not), equivalent behavior is provided by having a single null value.
  27. None
  28. None
  29. Null’s inventor

  30. Sir Tony Hoare “I call it my billion-dollar mistake. It

    was the invention of the null reference in 1965.”
  31. Billion dollar mistake.

  32. None
  33. None
  34. None
  35. None
  36. None
  37. Optional

  38. None
  39. Multimaps

  40. None
  41. Key -> List of Values

  42. None
  43. Aygul - [2] Mateusz - [1,2,3]

  44. Immutable Collections

  45. Mutable state

  46. None
  47. Mutable state

  48. Mutable state - Race conditions (multiple threads anyone?)

  49. Mutable state - Race conditions (multiple threads anyone?) - Harder

    debugging (what/who caused THAT change to my object?)
  50. Mutable state - Race conditions (multiple threads anyone?) - Harder

    debugging (what/who caused THAT change to my object?) - Do you trust your libraries?
  51. Srsly

  52. Do you trust them?

  53. None
  54. None
  55. Okay, don’t be that paranoid maybe.

  56. Usually you can trust your libraries.

  57. But!

  58. You don’t want to trust your co- workers, don’t you?

  59. Immutable = Not changed over time.

  60. None
  61. Also: - ImmutableMap - ImmutableSet - ...

  62. Caches

  63. Some operations are heavy

  64. And we want to avoid invoking them more that it’s

    needed
  65. Caches are hard

  66. Caches - Expiration

  67. Caches - Expiration - Invalidation

  68. Caches - Expiration - Invalidation - Weight/Sizes...

  69. Caches - Expiration - Invalidation - Weight/Sizes… - … aaand

    that’s only beginning!
  70. None
  71. Guava is huge!

  72. Preconditions Concurrency I/O EventBus! (but don’t use it on Android)

    Tons of utilities
  73. https://code.google.com/p/guava- libraries/wiki/GuavaExplained

  74. Last note.

  75. 65K method limit, anyone?

  76. Proguard in debug - no obfuscation, just shrinking unused methods

  77. Proguard in debug - no obfuscation, just shrinking unused methods.

    Multidex
  78. Proguard in debug - no obfuscation, just shrinking unused methods.

    Multidex jar stripping?
  79. There are WAYS

  80. Just give it a try

  81. and become a Guava addict

  82. ?