Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
3 libraries you want to keep in mind for realm
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
daimarom
December 19, 2017
Programming
470
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
3 libraries you want to keep in mind for realm
Realmを導入するなら覚えておきたいライブラリ三選
potatotips#46
https://potatotips.connpass.com/event/73328/
daimarom
December 19, 2017
More Decks by daimarom
See All by daimarom
(Flutterテストの)沼にハマってやってみた
daimarom
2
1.8k
角丸? それxfermodeで出来るよ
daimarom
0
390
Other Decks in Programming
See All in Programming
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
260
contenteditable と日本語入力に向き合う
colorful12
0
200
ジョジョの世界をXRで再現する
mofurune
0
160
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
170
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
770
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.6k
phperだってパンチカードでコーディングしたい
o0h
PRO
0
330
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
160
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
1.1k
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
250
Agents on Rails - Rails at Scale 2026
irinanazarova
0
540
ChromeでローカルLLM
ryu1013
0
140
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
Building an army of robots
kneath
307
47k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Building Applications with DynamoDB
mza
96
7.2k
Site-Speed That Sticks
csswizardry
13
1.6k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
ラッコキーワード サービス紹介資料
rakko
1
5.3M
What's in a price? How to price your products and services
michaelherold
247
13k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
Transcript
Realmを導入するなら 覚えておきたい ライブラリ三選 potatotips#46 2017.12.18
自己紹介 面白法人カヤック / ゲームコミュニティ事業部(Lobi、Lobiトーナメント) 室山大輔 Lobi(※) アプリエンジニア(Android) ※ スマホゲームに特化したSNS
Realm The perfect backend for the next generation of reactive
mobile apps 次世代のリアクティブなモバイルアプリのための完璧なバックエンド APIがシンプルなので、実装がとても楽 とにかく速い(特にquery) 中の人に直接質問できる公式のslackチャンネルがある しかし Realm Java にはちょっと面倒な手続きが…
Realmにおけるモデルクラスの制約 • 引数なしのコンストラクタが必要 • getter, setterが必要だった • 差分アップデートをしたければ、ビルダーを 用意するなりして、自分で何とかする 大抵は
Android Studio が自動生成してくれる 本質的ではないコードを用意するのは少し面倒 モデルクラスが増えれば、更に面倒に public class TestEntity extends RealmObject { @PrimaryKey public String id; public String getId() { return id; } public void setId(String id) { this.id = id; } public TestEntity() { } public TestEntity(String id) { this.id = id; } }
lombok Project Lombok getter/setter, equals/hashCode, toString など ボイラープレートコードをコンパイル時に自動生成 コードがだいぶシンプルになる フィールド名の変更などにも、自動で追従
便利なアノテーションが他にもある(@Builder, @Value など) Javaのプロダクトであれば使える @NoArgsConstructor @AllArgsConstructor @Getter @Setter public class TestEntity extends RealmObject { @PrimaryKey public String id; }
フィールドの指定 Realmは、モデルクラスからスキーマを自動生成する 様々なタイミングでフィールド名(文字列)が必要 マジックストリングを毎度書くのは面倒だし、ミスしそうで怖い そもそも避けたい # クエリ RealmResults<TestEntity> results =
realm.where(TestEntity.class) .equalTo("name", "hoge") .equalTo("child.name", "fuga") .findAll(); # マイグレーション schema.create(TestEntity.class.getSimpleName()) .addField("name", String.class, FieldAttribute.INDEXED) .addField("description", String.class, FieldAttribute.INDEXED) .addRealmObjectField("child", childSchema);
Realm Field Names Helper cmelchior/realmfieldnameshelper フィールド名(文字列)の定数を自動生成 ちょっと面倒なリンククエリ用の定数も生成してくれる # マイグレーション schema.create(TestEntity.class.getSimpleName())
.addField(TestEntityFields.NAME, String.class, FieldAttribute.INDEXED) .addField(TestEntityFields.CHILD.NAME, String.class, FieldAttribute.INDEXED) .addRealmObjectField(TestEntityFields.CHILD.$, childSchema); # クエリ RealmResults<TestEntity> results = realm.where(TestEntity.class) .equalTo(TestEntityFields.NAME, "hoge") .equalTo(TestEntityFields.CHILD.NAME, "fuga") .findAll();
デバッグログ 動作ログ、パフォーマンス計測、ボトルネックの特定、引数・返り値の確認など さまざまな用途でデバッグログの出力が必要 毎回自分で書くのは面倒 ビルドタイプに応じて、ログ出力の有無を 制御しないと、パフォーマンスに影響 public RealmResult<TestEntity> getTest() {
TimingLogger logger = new TimingLogger(TAG, "getTest"); Realm realm = getRealm(); logger.addSplit("get realm"); RealmResults<TestEntity> results = realm.where(TestEntity.class) .equalTo(TestEntityFields.NAME, "hoge") .equalTo(TestEntityFields.CHILD.NAME, "fuga") .findAll(); logger.addSplit("get test"); logger.dumpToLog(); return result; }
Hugo JakeWharton/hugo メソッドの引数・返り値、実行時間を自動出力 デバッグビルドの場合のみ出力 @DebugLog public RealmResult<TestEntity> getTest() { Realm
realm = getRealm(); RealmResults<TestEntity> results = realm.where(TestEntity.class) .equalTo(TestEntityFields.NAME, "hoge") .equalTo(TestEntityFields.CHILD.NAME, "fuga") .findAll(); return result; } # logcat V/TestProviderImpl: ⇢ getTest() V/TestProviderImpl: ⇠ getTest [2ms] = []
まとめ Realmはすごくいい感じ 今回紹介したようなライブラリを使うと、もっといい感じ 面倒事は極力なくして、本質的なロジックの実装に注力したいですね
ありがとうございました