إعادة بناء Duolingo على Android باستخدام مكتبات MVVM وJetpack
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
Duolingo هو تطبيق تعلُّم اللغات الأكثر رواجًا على مستوى العالم، لأنّه تمت إدارته وجعل ميزاته سهلة وممتعة بالنسبة إلى المستخدمين في الماضي. تتطلّب هذه التجربة اللغوية المرحة تدفقًا مستمرًا من الميزات والتجارب الجديدة إلى جانب تطبيق يعمل بسلاسة ويقدّم كل هذه الميزات. بالنسبة إلى Duolingo، قد يؤدي تثبيت تطبيق غير مستجيب على جهاز في أي مكان في العالم إلى شعور المتعلم بالإحباط. وهذا يدفعهم إلى التميز في التطبيق، وخصوصًا على أجهزة Android التي يستخدمها ستين في المائة من المتعلمين، بما في ذلك الرئيس التنفيذي، الذي يتتبّع التطبيق من هاتف مستوى المبتدئين. ولذلك، عندما لاحظ فريق تطوير تطبيقات Android في Duolingo زيادة في أخطاء "التطبيق لا يستجيب"، وتم تجاهل الإطارات، بل وتلقّى شكاوى مكتوبة بخط اليد، اتخذوا إجراءً على الفور.
وسرعان ما اكتشفوا مصدر مشكلات أداء التطبيق: حيث لم تكن بنية البرامج الحالية تتوسع بشكل جيد مع نمو فريقهم. أدّت التحديثات الضرورية إلى تراجع كبير في أداء التطبيق. وكان مطوّرو التطبيق يخصّصون وقتًا أطول لإصلاح الأخطاء، ويخصّصون وقتًا أقل لتسليم ميزات جديدة تؤدّي إلى تحقيق الأرباح. بدأت بنية برامجهم القديمة في أن تصبح عقبة غير مقبولة - عليها، وسرعة فريقهم، وقبل كل شيء، على تجربة المستخدمين. لقد احتاجت إلى إعادة إنشاء قاعدة الرموز الخاصة بها من الألف إلى الياء.
كيفية التنفيذ
في البداية، كان الفريق ممزقًا. هل يجب أن تكون هذه أولويتهم الوحيدة الآن؟ شعرت إحدى المجموعات بأهمية الاستمرار في توفير ميزات جديدة وزيادة الأرباح، بينما رأت المجموعة الأخرى أنّ تركيز كل اهتمامها على إعادة تشغيل Android كان المضي قدمًا. وفي نهاية المطاف، توصلوا إلى إجماع أن الجهد المتزايد المبذول لمكافحة الانحدارات قد تسبب في عرقلة خارطة الطريق تمامًا. كان عليهما الانخراط في كل شيء.
واستقر الفريق على حل يتزايد رواجه. قرّر الفريق إعادة كتابة تطبيقه باستخدام Model-View-ViewModel، وهو نمط برمجي توفّره Google يتيح للمطوّرين تبسيط بنية التطبيق من خلال الفصل بين المخاوف بوضوح. وباستخدام MVVM، استطاعوا فصل تطوير واجهة المستخدم الرسومية (العرض) عن تطوير منطق العمل (النموذج). ويمكنهم وضع أنماط واضحة ومتفق عليها، مما يسهل مواءمة نهجهم مع الميزات الجديدة، وإشراك المطورين القادمين.
إنّ تقسيم كل ميزة إلى وحدة نموذجية خاصة بها سمح للفريق باستعادة الإنتاجية بسرعة، إذ تمكّن من تعيين مجموعات صغيرة للعمل على كل ميزة بالتوازي، ما يؤدي إلى زيادة السرعة مع تقليل الأخطاء.
وقد طبّقوا هذه البنية الجديدة باستخدام مكتبات من Jetpack على Android، بما في ذلك Dagger وHilt، لمساعدتهم على كتابة الرموز البرمجية التي تعمل باستمرار على جميع إصدارات Android وأجهزته. وقد مكنتهم هاتان الإضافتان من إنشاء ميزات مُغلّفة بشكل أفضل واستخدام الوحدات المضمَّنة في Android بكفاءة أكبر.
النتائج
يؤدي هذان الأداء إلى تحسين تجربة المتعلّمين بشكل كبير على Android وخاصةً على أجهزة المبتدئين. كما أدى ذلك إلى تطبيق أكثر استجابة يتميز برسوم متحركة أكثر سلاسة على الأجهزة الرئيسية. انخفضت النسبة اليومية لأخطاء "التطبيق لا يستجيب" أو أخطاء ANR بنسبة 41%. إنّ النسبة المئوية للوقت الذي انخفض فيه التطبيق عن عدد اللقطات المستهدَف في الثانية انخفض بنسبة 28%. والأهم من ذلك، شهد المستخدمون زيادة بنسبة 40٪ في السرعة عند التمرير عبر الشاشات الرئيسية.
تضع يدها ملاحظات ككاتبة تشير إلى أخطاء ANR بنسبة% 41 ومعدل عرض إطارات محسَّن بنسبة% 28 وتجربة أسرع بنسبة% 40.
استغرقت إعادة التشغيل بالكامل ثمانية أسابيع وساهمت في جعل التطبيق أكثر جاذبية ومتعة لجميع متعلّمي Duolingo. وعلى مدى الأشهر الستة التي تلت تطبيق هذا التغيير، لم يسجّل الفريق أي تراجع كبير في الأداء، ما سمح له بالتركيز مرة أخرى على ميزات تحقيق أرباح الشحن. وقد أتى قرار تركيز جهود الفريق على الجودة بجدية.
بفضل التزام Duolingo بهدف تحقيق رسالتهم، أصبح التطبيق الأفضل في العالم في مجال تعلُّم اللغات. إنّ التزامهم بالتميّز في التطبيقات من خلال توفير تجارب تعليمية متطوّرة بدون المساس بتسهيل الاستخدام هو ما ساهم في عدم نجاح التطبيقات.
البدء
إذا كنت تريد التعمق في التفاصيل الجوهرية لكيفية دمج Duolingo لمكتبات Jetpack، والطريقة التي ساهمت بها ميزة Model-View-ViewModel في تحسين تطبيقها، يمكنك الاطّلاع على دراسة الحالة الفنية للمطوّرين.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2021-08-19 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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."]]