Refactor های Duolingo در اندروید با کتابخانه های MVVM و Jetpack
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Duolingo محبوبترین برنامه یادگیری زبان در جهان است زیرا توانسته چیزی را که مردم در گذشته دلهرهآور میدانستند، آسان و سرگرمکننده کند. این تجربه زبانی به جریانی ثابت از ویژگیها و آزمایشهای جدید نیاز دارد - و یک برنامه روان که بتواند همه آنها را ارائه دهد. برای Duolingo، یک برنامه بدون پاسخ در دستگاهی در هر نقطه از جهان می تواند به معنای یک یادگیرنده بالقوه دلسرد باشد. این آنها را متعهد به برتری برنامهها میکند، بهویژه در دستگاههای اندرویدی که شصت درصد زبانآموزانشان از آنها استفاده میکنند، از جمله مدیر عامل آنها، که برنامه را از یک تلفن سطح پایه پیگیری میکند. و بنابراین، هنگامی که تیم توسعه اندروید Duolingo متوجه افزایش خطاهای «App not Responding» شد، فریمها را رها کردند - و حتی شکایات دستنویس دریافت کردند - بلافاصله وارد عمل شدند.
آنها به زودی منبع مشکلات عملکرد برنامه را کشف کردند: معماری نرم افزار موجود با رشد تیم آنها به خوبی مقیاس نمی شد. بهروزرسانیهای ضروری باعث رگرسیونهای عملکرد دردناکی در برنامه میشدند. توسعه دهندگان آنها زمان بیشتری را به رفع اشکالات و کمتر به ارسال ویژگی های جدید درآمدزا اختصاص می دادند. معماری نرم افزار منسوخ شده آنها شروع به تبدیل شدن به یک کشش غیرقابل قبول کرده بود - بر آنها، سرعت تیم آنها، و مهمتر از همه، تجربه کاربرانشان. آنها نیاز داشتند که پایگاه کد خود را از ابتدا بازسازی کنند.
چگونه این کار را انجام دادند
در ابتدا تیم پاره شد. آیا اکنون این باید تنها اولویت آنها باشد؟ یک گروه احساس کردند که ادامه ارسال ویژگی های جدید و افزایش درآمد مهم تر است، در حالی که گروه دیگر معتقد بودند که تمرکز تمام توجه خود بر راه اندازی مجدد اندروید راه رو به جلو است. سرانجام، آنها به اجماع رسیدند که تلاش فزاینده برای مبارزه با رگرسیون خطر از بین بردن کامل نقشه راه آنها را در پی دارد. آنها مجبور بودند آل-این بروند.
تیم به یک راه حل رو به افزایش محبوبیت رسید. آنها تصمیم گرفتند برنامه خود را با استفاده از Model-View-ViewModel بازنویسی کنند، یک الگوی نرمافزاری که توسط گوگل پشتیبانی میشود و به توسعهدهندگان اجازه میدهد تا معماری برنامه را با ایجاد تفکیک واضح نگرانیها سادهسازی کنند. با MVVM، آنها می توانند توسعه رابط کاربری گرافیکی (نما) را از توسعه منطق تجاری (مدل) جدا کنند. آنها میتوانند الگوهای واضح و توافقشدهای را ایجاد کنند و همسو کردن رویکردشان با ویژگیهای جدید و توسعهدهندگان ورودی را آسانتر کند.
شکستن هر ویژگی به قطعه مدولار خود به تیم اجازه داد تا به سرعت بهرهوری را به دست آورد، زیرا آنها میتوانستند گروههای کوچکی را به کار موازی روی هر ویژگی اختصاص دهند و سرعت را افزایش دهند و در عین حال خطاها را کاهش دهند.
آنها این معماری جدید را با کتابخانههایی از Jetpack Android، از جمله Dagger و Hilt ، پیادهسازی کردند تا به آنها کمک کند کدی بنویسند که به طور مداوم در نسخهها و دستگاههای Android کار کند. این دو افزوده به آنها امکان میدهد ویژگیهای محصورشده بهتری ایجاد کنند و از ماژولهای داخلی اندروید به طور مؤثرتری استفاده کنند .
نتایج
این عملکرد به طور قابل توجهی باعث بهبود تجربه یادگیرندگان در Android و به ویژه در دستگاه های سطح ابتدایی می شود. آنها همچنین منجر به یک برنامه پاسخگوتر با انیمیشن های روان تر در دستگاه های پرچمدار شدند. نرخ روزانه "App Not Responsing" یا ANR 41٪ کاهش یافته است. درصد زمانی که برنامه به زیر نرخ فریم هدف خود میرسد، 28 درصد کاهش یافته است. مهمتر از همه، کاربران آنها هنگام پیمایش در صفحه کلید، 40 درصد افزایش سرعت را تجربه کردند.

دستهایی که یادداشتهایی را در دست گرفتهاند، ۴۱ درصد ANR کمتر، ۲۸ درصد نرخ فریم بهبود یافته و ۴۰ درصد تجربه سریعتر را میخوانند.
کل راهاندازی مجدد هشت هفته طول کشید و برنامه را برای همه زبانآموزان Duolingo بسیار جذابتر و لذتبخشتر کرد. در شش ماه پس از آن، تیم هیچ رگرسیون عملکرد قابل توجهی ثبت نکرده است، که به آنها اجازه می دهد دوباره بر روی ویژگی های درآمدزا حمل و نقل تمرکز کنند. تصمیم برای تمرکز تلاش تیم بر کیفیت نتیجه داده بود.
تعهد Duolingo به مأموریت خود، آنها را به برترین برنامه جهان در فضای یادگیری زبان تبدیل کرد. تعهد آنها به برتری برنامه - ایجاد تجربیات آموزشی پیشرفته بدون به خطر انداختن دسترسی - چیزی است که آنها را در آنجا نگه داشته است.
شروع کنید
اگر دوست دارید در مورد نحوه ادغام کتابخانه های Jetpack توسط Duolingo و اینکه Model-View-ViewModel برنامه خود را بهبود بخشیده است غواصی کنید، مطالعه موردی فنی ما را برای توسعه دهندگان بخوانید.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و 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."]]