Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
3 libraries you want to keep in mind for realm
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
daimarom
December 19, 2017
Programming
460
0
Share
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.7k
角丸? それxfermodeで出来るよ
daimarom
0
370
Other Decks in Programming
See All in Programming
GitHubCopilotCLIをはじめよう.pdf
htkym
0
330
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
200
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
160
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
1.1k
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
1.1k
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
120
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
360
実践ハーネスエンジニアリング:ステアリングループを実例から読み解く / Practical Harness Engineering: Understanding Steering Loops Through Real-World Examples
nrslib
5
5.5k
「なんか〇〇ライブラリで脆弱性あるみたいなんだけど。。。」から始める脆弱性対応 / First Steps in Vulnerability Response
mackey0225
2
130
開発体験を左右するライブラリの API 設計 - GraphQL スキーマ構築ライブラリから考える #tskaigi
izumin5210
1
110
AWSはOSSをどのように 考えているのか?
akihisaikeda
0
120
PHPでバイナリをパースして理解するASN.1
muno92
PRO
0
460
Featured
See All Featured
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.4k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
170
Odyssey Design
rkendrick25
PRO
2
620
Google's AI Overviews - The New Search
badams
0
1k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
420
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
150
How to Think Like a Performance Engineer
csswizardry
28
2.6k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
820
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はすごくいい感じ 今回紹介したようなライブラリを使うと、もっといい感じ 面倒事は極力なくして、本質的なロジックの実装に注力したいですね
ありがとうございました