Slide 1

Slide 1 text

ORMͷબͼํ ~ Androidฤ ~ #potatotips 2016/03/16 @__gfx__

Slide 2

Slide 2 text

ࣗݾ঺հ • Engineer at eBook Initiative Japan • Android Engineer • Recent Works: Android ORM, Static Gson, Robolectric-Instrumentation • rebuild.fm/133 ͰAndroid Nͷ࿩Λͨ͠

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

ORM for Android • ͍·͍ͪϕετϓϥΫςΟε͕ఆ·Βͳ͍ྖҬ • ੲ͸ʮ࢖͍΍͢͞ͷActiveAndroidʯͱʮ଎౓ͷ GreenDAOʯ͘Β͍͔͠બ୒ࢶ͕ͳ͔ͬͨ • ࠓ͸΄͔ʹDBFlow, Requery, OrmaͳͲଟ਺ • NoSQLͷRealm΋ORMػೳΛ΋ͭDBͱͯ͠஫໨͞Ε ͍ͯΔ

Slide 5

Slide 5 text

ORMʹٻΊΔ΋ͷ • ଎౓: ϦϑϨΫγϣϯ͸஗͍ɻίʔυੜ੒͢΂͖ • ϚΠάϨʔγϣϯ: ϚΠάϨʔγϣϯ͕ͭΒ͍ͱ ؾܰʹ࢖͑ͳ͍ɻΧϥϜͷ௥Ճ͘Β͍ࣗಈͰ΍ͬ ͯ͘Ε • ؆୯: ੍໿Λ՝͞ͳ͍͜ͱʢe.g. ಛఆͷεʔύʔ Ϋϥε͕ඞཁʣɺίʔυิ׬ͱͷ૬ੑͷΑ͞

Slide 6

Slide 6 text

଎౓ • AA: ϦϑϨΫγϣϯ࢖༻ɻ஗͍ • DBFlow, Orma: ίʔυੜ੒ɻ଎͍ • Realm: ಠࣗDB࣮૷ɻ଎͍ ※ ͳ͓Realm͸ߴ଎ͱ͍ΘΕΔ͕ɺOrma΍DBFlowͱ ͘Β΂Δͱʮ଎͍έʔε͕͋Δʯͱ͍͏ఔ౓

Slide 7

Slide 7 text

ϚΠάϨʔγϣϯ • खͰϚΠάϨʔγϣϯίʔυΛॻ͖ͨ͘ͳ͍ w ""WFSTJPOTRMʹ42-Λॻ͘ w %#'MPXBEE$PMVNO -POHDMBTT UJNFTUBNQ w 0SNBϦωʔϜҎ֎͸ίʔυෆཁ w 3FBMNBEE'JFME JE MPOHDMBTT

Slide 8

Slide 8 text

؆୯͞(1): Ϟσϧͷ੍໿ • ActiveAndroid΍Realm͸ModelΫϥεΛܧঝ͢Δඞཁ͕͋Γɺ JSON serializeͳͲͰϋϚΔ • AA͸উखʹprimary keyΛ͚ͭͯϋϚΔ • Orma, Requery͸੍໿ͳ͠ɺDBFlow͸ΠϯλʔϑΣΠεͷ࣮૷ ΛٻΊΔ ※ ҎલͷRelamϞσϧ͸ϝιουΛఆٛͰ͖ͳ͍ͳͲͷ੍໿͕͋ͬ ͕ͨɺv0.88Ͱ΄ͱΜͲղফ͞Εͨ

Slide 9

Slide 9 text

؆୯͞(2): ΫΤϦϏϧμ • ίʔυίϯϓϦʔτͱͷ૬ੑΛߟ͑Δ • ""OFX4FMFDU GSPN *UFNDMBTT XIFSF OBNF +BDL • %#'MPX 42-JUFTFMFDU GSPN *UFNDMBTT XIFSF *UFN@5BCMFOBNFFR +BDL • 0SNBPSNBTFMFDU'SPN*UFN OBNF&R +BDL • 3FBMNSFBMNXIFSF *UFNDMBTT FRVBMT OBNF +BDL

Slide 10

Slide 10 text

݁࿦ • AAΛ࢖͏ཧ༝͸ͳ͍ • Orma͸·͋·͋ΠέͯΔ • DBFlow΋ͳ͔ͳ͔Α͍ɻϚΠάϨʔγϣϯ͠ͳ͍ͳ Β • Realm΋0.88͔Β͍ͩͿΑ͘ͳͬͨɻϚΠάϨʔγϣ ϯ͠ͳ͍ͳΒ

Slide 11

Slide 11 text

OrmaͷΠέͯͳ͍ͱ͜Ζ • ރΕͯͳ͍ʢ։ൃΛ͸͡Ίͯ3ϲ݄͘Β͍ʣ • ෳࡶͳΫΤϦΛߏஙͰ͖ͳ͍ • has-one, has-many, many-to-manyͳͲͷ associationsͷαϙʔτ͕ශऑ • ίʔυੜ੒ܥҰൠͷ࿩ͱͯ͠ɺίϯύΠϧΤϥʔʹ ͳͬͨͱ͖ʹؔ܎ͳ͍Τϥʔ͕େྔʹग़ͯͭΒ͍

Slide 12

Slide 12 text

͓·͚: APK sizes • Normal App: 0.85MiB • Orma App: 0.97MB • Realm App: 5.30MB https://github.com/gfx/ORM-APK-Size-Example

Slide 13

Slide 13 text

https://github.com/gfx/Android-Orma