Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Java is not perfect.

Slide 3

Slide 3 text

Actually

Slide 4

Slide 4 text

Java sucks.

Slide 5

Slide 5 text

Java sucks. At least compared to other languages.

Slide 6

Slide 6 text

Scala?

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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; } }

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Mateusz Herych GDG Kraków Android GDE Engineer, Base CRM

Slide 18

Slide 18 text

Guava

Slide 19

Slide 19 text

Google’s Java

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

null

Slide 25

Slide 25 text

Wikipedia

Slide 26

Slide 26 text

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.

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Null’s inventor

Slide 30

Slide 30 text

Sir Tony Hoare “I call it my billion-dollar mistake. It was the invention of the null reference in 1965.”

Slide 31

Slide 31 text

Billion dollar mistake.

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Optional

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Multimaps

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Key -> List of Values

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

Aygul - [2] Mateusz - [1,2,3]

Slide 44

Slide 44 text

Immutable Collections

Slide 45

Slide 45 text

Mutable state

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Mutable state

Slide 48

Slide 48 text

Mutable state - Race conditions (multiple threads anyone?)

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

Mutable state - Race conditions (multiple threads anyone?) - Harder debugging (what/who caused THAT change to my object?) - Do you trust your libraries?

Slide 51

Slide 51 text

Srsly

Slide 52

Slide 52 text

Do you trust them?

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

Okay, don’t be that paranoid maybe.

Slide 56

Slide 56 text

Usually you can trust your libraries.

Slide 57

Slide 57 text

But!

Slide 58

Slide 58 text

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

Slide 59

Slide 59 text

Immutable = Not changed over time.

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

Also: - ImmutableMap - ImmutableSet - ...

Slide 62

Slide 62 text

Caches

Slide 63

Slide 63 text

Some operations are heavy

Slide 64

Slide 64 text

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

Slide 65

Slide 65 text

Caches are hard

Slide 66

Slide 66 text

Caches - Expiration

Slide 67

Slide 67 text

Caches - Expiration - Invalidation

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

Caches - Expiration - Invalidation - Weight/Sizes… - … aaand that’s only beginning!

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

Guava is huge!

Slide 72

Slide 72 text

Preconditions Concurrency I/O EventBus! (but don’t use it on Android) Tons of utilities

Slide 73

Slide 73 text

https://code.google.com/p/guava- libraries/wiki/GuavaExplained

Slide 74

Slide 74 text

Last note.

Slide 75

Slide 75 text

65K method limit, anyone?

Slide 76

Slide 76 text

Proguard in debug - no obfuscation, just shrinking unused methods

Slide 77

Slide 77 text

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

Slide 78

Slide 78 text

Proguard in debug - no obfuscation, just shrinking unused methods. Multidex jar stripping?

Slide 79

Slide 79 text

There are WAYS

Slide 80

Slide 80 text

Just give it a try

Slide 81

Slide 81 text

and become a Guava addict

Slide 82

Slide 82 text

?