MVVM と Jetpack ライブラリを使用して Android で Duolingo をリファクタリング
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Duolingo は、世界で最も人気のある言語学習アプリです。Duolingo は、過去に不可能だと思ったことを簡単で楽しいものにすることが可能でした。この心地よい言語体験を実現するには、新しい機能と実験が絶えず与えられることと、そのすべてを提供できるスムーズ実行アプリが必要です。Duolingo で、世界中のどのデバイスでもアプリが反応しないというのは、学習者のやる気を失うことになりかねません。これにより、学習者の 60% が使用している Android デバイスで優れたアプリを提供できるようになります。CEO はエントリー レベルのスマートフォンからアプリを追跡しています。そこで、Duolingo の Android 開発チームは、「アプリから応答しない」エラーの増加に気づき、フレームを落とし、さらには手書きの苦情を受け付けて、ただちに対策を講じました。
すぐにアプリのパフォーマンスの問題の原因が明らかになりました。既存のソフトウェア アーキテクチャがチームの成長に合わせてうまくスケーリングできていないというものでした。必要な更新がアプリのパフォーマンス低下を引き起こしました。開発者は、バグ修正に多くの時間を費やし、収益を生み出す新機能のリリースに多くの時間を費やしていました。同社の古いソフトウェア アーキテクチャは、自分たちにとっても、チームのスピードと、そして何よりもユーザー エクスペリエンスにとって、受け入れがたい抵抗になり始めていました。コードベースを一から再構築する必要がありました。
実現手法
最初はチームが混乱し、本件を現時点で唯一の優先事項とするべきでしょうか?一方のグループは、新機能を継続的にリリースして収益を上げることのほうが重要であると感じ、もう 1 グループは、Android の再起動に全力を注ぐべきだと考えていました。最終的には、回帰対策の取り組みの増大が、ロードマップを完全に逸脱するリスクがあるというコンセンサスにたどり着きました。全力を尽くさなければなりませんでした。
そして、人気が高まっているソリューションに決着しました。そこで、Model-View-ViewModel を使用してアプリを書き換えることにしました。このソフトウェア パターンは Google がサポートするソフトウェア パターンで、これによりデベロッパーは懸念事項を明確に分離することで、アプリのアーキテクチャを効率化できます。MVVM を使用すると、グラフィカル ユーザー インターフェース(ビュー)の開発とビジネス ロジック(モデル)の開発を分離できます。明確で合意されたパターンを確立できるため、新機能に対するアプローチの調整と今後のデベロッパーのオンボーディングの両方が容易になります。
各機能を個別のモジュール方式にしたことで、少人数のグループを割り当てて各機能を並行して作業できるようになったため、チームは迅速に生産性を取り戻すことができました。その結果、作業速度が向上し、エラーが減少しました。
そこで、Android の Jetpack ライブラリ(Dagger や Hilt など)を使用してこの新しいアーキテクチャを実装し、Android のバージョンやデバイスを問わず一貫して動作するコードを記述できるようにしました。この 2 つの追加により、カプセル化された機能を改善し、Android の組み込みモジュールをより効率的に活用できるようになりました。
結果
これらのパフォーマンスにより、Android、特にエントリレベルのデバイスでの学習者のエクスペリエンスは大幅に向上します。また、主力デバイスでは、アプリの応答性が向上し、アニメーションがより滑らかになりました。1 日の「アプリから応答なし」または ANR 発生率が 41% 低下しました。アプリが目標フレームレートを下回った時間の割合が 28% 減少しました。特に重要なのは、主要な画面をスクロールする際の速度が 40% 上昇したことです。
持ち手のメモでの ANR が 41% 減少し、フレームレートが 28% 向上し、エクスペリエンスが 40% 高速化。
全体の再起動は 8 週間で完了し、Duolingo の学習者全員にとって、アプリの魅力と満足度が大幅に高まりました。それ以来 6 か月間、大きなパフォーマンスの低下は見られず、収益を生み出す機能の開発に再び注力できるようになりました。品質に重点を置くという決断は実を結び、
その使命を果たすための Duolingo は、言語学習分野で世界最高のアプリになりました。ユーザー補助を犠牲にすることなく最先端の教育体験を生み出すという、優れたアプリへの取り組みが、同氏を支えています。
始める
Duolingo で Jetpack のライブラリを統合した方法や、Model-View-ViewModel がアプリをどのように改良したかについて詳しく知りたい場合は、デベロッパー向けの技術的な事例紹介をご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2021-08-19 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2021-08-19 UTC。"],[],[],null,["# Duolingo refactors on Android with MVVM and Jetpack libraries\n\nDuolingo is the world's most popular language learning app because it's managed to make something people have found daunting in the past feel easy and fun. This breezy language experience requires a constant stream of new features and experiments --- and a smooth-running app that can deliver all of them. To Duolingo, an unresponsive app on a device anywhere in the world could mean a potentially discouraged learner. This commits them to app excellence, particularly on the Android devices used by sixty percent of their learners, including their CEO, who keeps track of the app from an entry-level phone. And so, when Duolingo's Android development team noticed an increase in \"App not Responding\" errors, dropped frames --- and even received hand-written complaints --- they took action immediately.\n\nThey soon uncovered the source of the app's performance issues: the existing software architecture wasn't scaling well with the growth of their team. Necessary updates were causing painful performance regressions on the app. Their developers were devoting more time to fixing bugs, and less to shipping new revenue-generating features. Their outdated software architecture was starting to become an unacceptable drag --- on them, their team velocity, and, above all, on their users' experience. They needed to rebuild their codebase from the ground up.\n\nHow they did it\n---------------\n\nAt the beginning, the team was torn. Should this be their sole priority now? One group felt that it was more important to continue shipping new features and driving revenue, while the other believed that focusing all their attention on an Android reboot was the way forward. Eventually, they reached the consensus that the increasing effort of fighting regressions risked derailing their road map entirely. They had to go all-in.\n\nThe team settled on an increasingly popular solution. They decided to rewrite their app\nusing [Model-View-ViewModel](https://developer.android.com/jetpack/guide?gclid=Cj0KCQjw6s2IBhCnARIsAP8RfAj6I4mhRRdSqjYfPlvGET9S6mmRGJrc8Inkc-cCe1IVdTDEvlE3hFEaApHkEALw_wcB&gclsrc=aw.ds), a software pattern supported by Google that allows developers to streamline an app's architecture by creating clear separation of concerns. With MVVM, they could separate the development of the graphical user interface (the view) from the development of the business logic (the model). They could establish clear and agreed upon patterns, making it easier to both align their approach to new features and onboard incoming developers.\n\nBreaking each feature into its own modular piece allowed the team to quickly regain productivity, as they could assign small groups to work on each feature in parallel, increasing velocity while reducing errors.\n\nThey implemented this new architecture with libraries from Android's [Jetpack](https://developer.android.com/jetpack), including [Dagger](https://developer.android.com/training/dependency-injection/dagger-basics) and [Hilt](https://developer.android.com/training/dependency-injection/hilt-android), to help them write code that works consistently across Android versions and devices. These two additions enabled them to create better encapsulated features and [utilize Android's built-in modules more efficiently](https://developer.android.com/training/dependency-injection).\n\nResults\n-------\n\nThese performance gains significantly improved learners' experience on Android and in particular on entry-level devices. They also led to a more responsive app with smoother animations on flagship devices. The daily \"App Not Responding\" or ANR rate dropped 41%. The percentage of time that the app fell below its target frame rate decreased by 28%. Most importantly, their users experienced a 40% increase in speed when scrolling through key screens.\n\n\n*Hands holding notes reading 41% less ANRs, 28% improved frame rate and 40% faster experience.*\n\n\u003cbr /\u003e\n\nThe whole reboot took eight weeks and made the app considerably more engaging and delightful for all Duolingo learners. In the six months since, the team has recorded no significant new performance regressions, allowing them to focus again on shipping revenue-generating features. The decision to focus the team's efforts on quality had paid off.\n\nDuolingo's dedication to their mission made them the world's top app in the language learning space. Their commitment to app excellence --- creating cutting edge educational experiences without compromising accessibility --- is what kept them there.\n\nGet started\n-----------\n\nIf you feel like diving into the nitty-gritty of how Duolingo integrated Jetpack's libraries, and how Model-View-ViewModel improved their app, read our [technical case study](https://android-developers.googleblog.com/2021/08/android-app-excellence-duolingo.html) for developers."]]