تقلل SmartNews من أسطر الرموز بنسبة 20٪ وتحسن الروح المعنوية للفريق باستخدام Kotlin.
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.

تساعد SmartNews
الملايين من الأشخاص في استكشاف عالمهم كل يوم من خلال مشاركة أخبار في الوقت المناسب
من مجموعة متنوعة من مصادر الأخبار. تأسست الشركة في العام 2012 في اليابان،
وأصبحت الآن أكثر من 50 مليون عملية تنزيل على مستوى العالم.
في حزيران (يونيو) 2019، رأى الفريق توجه تطوير Android نحو لغة Kotlin أولاً وقرروا بدء اختبار Kotlin بأنفسهم. لقد أرادوا الاستفادة من مكتبات Jetpack التي تعتمد على لغة Kotlin أولاً، وتقليل عدد الرموز البرمجية المطلوب صيانتها، والاستفادة من بنية Kotlin المعبِّرة والسهلة الفهم.
الإجراءات التي اتخذتها الشركة
يتمتع فريق SmartNews بخبرة واسعة في لغة Java، لذلك كان من السهل عليهم
بدء الكتابة باستخدام Kotlin. ونظرًا لأن لغة Kotlin قابلة للتشغيل التفاعلي بنسبة 100% مع لغة Java، يمكنهم
بسهولة البدء في كتابة ميزات جديدة مثل
Weather Radar وNews Radar وNews From All Sides
في Kotlin، أثناء العمل على قاعدة الرموز الحالية. واستخدموا الكوروتينات لإدارة تنزيل الصور والتخزين المؤقت داخل ميزة Weather Radar الحاصلة على براءة اختراع.
يقدّم مرسلو الكوروتين فكرة مجرّدة مفيدة لإدارة المهام، وقد ساعد هذا مهندسي SmartNews في تجنّب الأخطاء التي تنشأ عن إدارة سلاسل التعليمات الأولية.
كما أعاد الفريق أيضًا هيكلة بعض رموز Java الخاصة بهم، وأعجبهم
ميزات الأمان الخالية في Kotlin. إنّ بنية لغة Kotlin لتحديد قابلية التغيّر والقابلية للإبطال والتهيئة ساعدت الفريق على رصد الأخطاء في مرحلة مبكرة، وقلّلت الوقت اللازم لمراجعة تغييرات الرمز بنسبة 10%.
وباستخدام بناء الجملة الموجز والفعال لخدمة Kotlin، تمكّنوا أيضًا من زيادة سهولة قراءة قاعدة التعليمات البرمجية الخاصة بهم، مما سهّل صيانة التعليمات البرمجية الخاصة بهم مع استمرار الشركة في النمو.
النتائج
لقد حسّنت الكتابة بلغة Kotlin إنتاجيتها الإجمالية بدءًا من التنفيذ وحتى الإطلاق. إنّ أكبر تحسُّن شهدناه هو أنّ الكتابة باستخدام لغة Kotlin قللت من سطور الرمز المحوَّلة بنسبة 20%.
يتوفّر حاليًا نصف تطبيق SmartNews تقريبًا باستخدام لغة Kotlin، ويخطط فريق التطوير لكتابة جميع الميزات الجديدة بلغة Kotlin بالإضافة إلى إعادة هيكلة بعض الرموز البرمجية الحالية من أجل مواصلة زيادة إمكانية صيانة الرموز البرمجية.
وأثناء استخدام فريق التطوير في لغة البرمجة Kotlin وتقليل الرموز النموذجية، لاحظوا زيادة في معنويات الفريق. كان الفريق متحمسًا ليكون قادرًا على التعبير عن أفكاره بطريقة أكثر كفاءة، وجعل التعليمة البرمجية
أكثر سهولة في المستقبل. لاحظ "هيديو أوهاشي"، مدير الهندسة في SmartNews، أنّ Kotlin ساعدت في جهودها
في مجال التوظيف الهندسي. "أكثر الأسئلة شيوعًا من المرشحين هي "هل تستخدم لغة Kotlin؟ وماذا عن معدّل استخدامك له؟ يبدو الآن أنّ العديد من المهندسين مهتمون بالانتقال إلى استخدام لغة البرمجة Kotlin ويريدون دعمها". وعلى الرغم من أنّ هذه
التحسينات في معنويات الفريق والتوظيف لم تكن الأسباب الرئيسية
لاعتماد الفريق على لغة البرمجة Kotlin، إلا أنّ هذه التغييرات الإيجابية ستساعد الشركة مع استمرار نمو نشاطها في هذا المجال التنافسي.
البدء
اطّلِع على مزيد من المعلومات عن تطوير تطبيق Android باستخدام Kotlin.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2021-01-06 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-01-06 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# SmartNews reduces lines of code by 20% and improves team morale with Kotlin\n\n[SmartNews](https://play.google.com/store/apps/details?id=jp.gocro.smartnews.android)\nhelps millions of people discover their world everyday by sharing timely news\nfrom a diverse set of news sources. The company was founded in 2012 in Japan,\nand it now has over 50 million downloads globally.\n\nIn June 2019, the team saw Android development moving towards Kotlin first and\ndecided to start testing Kotlin themselves. They wanted to take advantage of\nKotlin-first Jetpack libraries, reduce the amount of code they had to maintain,\nand benefit from Kotlin's expressive and easy-to-understand syntax.\n\nWhat they did\n-------------\n\nThe team at SmartNews is well versed in Java, so it was fairly easy for them to\nstart writing in Kotlin. As Kotlin is 100% interoperable with Java, they could\neasily start writing new features such as\n[Weather Radar and News From All Sides](https://about.smartnews.com/en/2020/09/17/20200917/)\nin Kotlin, while working in their existing codebase. They used coroutines to\nmanage image downloading and caching within the patented Weather Radar feature.\nCoroutine dispatchers provide a useful abstraction for managing tasks, and this\nhelped the SmartNews engineers avoid the pitfalls that come from managing raw\nthreads.\n\nThe team also refactored some of their Java code, and was impressed with\nKotlin's null safety features. Kotlin's syntax for identifying mutability,\nnullability, and initialization helped the team catch errors early on,\nand **reduced the amount of time to review code changes by 10%**.\nUsing Kotlin's succinct and efficient syntax, they were also able to increase\nthe readability of their codebase, which has made their code easier to maintain\nas the company continues to grow.\n\nResults\n-------\n\nWriting in Kotlin has **improved their overall productivity from\nimplementation to launch** . The biggest improvement they saw was that\nwriting in Kotlin **reduced their converted lines of code by 20%**.\nApproximately half of the SmartNews app is currently in Kotlin, and the\ndevelopment team plans on writing all new features in Kotlin as well as\nrefactoring some of their existing code in order to continue increasing their\ncode maintainability.\n\nAs the development team was implementing Kotlin and reducing boilerplate code,\nthey noticed an **increase in team morale** . The team was excited\nto be able to express their ideas in a more efficient way, and have their code\nbe more readable for the future. Hideo Ohashi, the Engineering Manager for\nSmartNews noticed **Kotlin has helped their engineering recruiting\nefforts** . *\"The most frequent questions from candidates are 'are you\nusing Kotlin? How often do you use it?' It seems now that many engineers are\ninterested in migrating to Kotlin and want to support it.\"* While these\nimprovements in team morale and recruitment were not the main reasons the team\nadopted Kotlin, these positive changes will help the company as it continues to\ngrow in this competitive industry.\n\nGet started\n-----------\n\nLearn more about [developing an Android app with Kotlin](/kotlin)."]]