SmartNews riduce le righe di codice del 20% e migliora il morale del team con Kotlin
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.

SmartNews
aiuta milioni di persone a scoprire il loro mondo ogni giorno condividendo notizie tempestive
da una serie diversificata di fonti di notizie. L'azienda è stata fondata nel 2012 in Giappone
e ora vanta oltre 50 milioni di download in tutto il mondo.
Nel giugno 2019, il team ha visto inizialmente lo sviluppo Android passare a Kotlin e ha deciso di iniziare a testare Kotlin in autonomia. L'azienda voleva sfruttare le librerie Jetpack
Kotlin-first, ridurre la quantità di codice da gestire
e trarre vantaggio dalla sintassi espressiva e di facile comprensione di Kotlin.
Cosa hanno fatto
Il team di SmartNews è esperto di Java, quindi è stato abbastanza facile
iniziare a scrivere in Kotlin. Poiché Kotlin è interoperabile al 100% con Java, potrebbe
facilmente iniziare a scrivere nuove funzionalità come
Weather Radar e News From All Sides
in Kotlin, lavorando nel loro codebase esistente. Ha usato le coroutine per gestire il download e la memorizzazione nella cache delle immagini all'interno della funzionalità brevettata Weather Radar.
I supervisori delle Coroutine forniscono un'utile astrazione per la gestione delle attività e ciò ha aiutato gli ingegneri di SmartNews a evitare le insidie derivanti dalla gestione di thread non elaborati.
Il team ha anche eseguito il refactoring di parte del proprio codice Java ed è rimasto impressionato dalle funzionalità di sicurezza null di Kotlin. La sintassi di Kotlin per identificare la mutabilità, la nulla e l'inizializzazione ha aiutato il team a rilevare subito gli errori e a ridurre del 10%il tempo necessario per la revisione delle modifiche al codice.
Utilizzando la sintassi breve ed efficiente di Kotlin, l'azienda è stata anche in grado di aumentare la leggibilità del loro codebase, il che ha reso il codice più facile da gestire man mano che l'azienda continua a crescere.
Risultati
Scrivere in Kotlin ha migliorato la produttività complessiva dall'implementazione al lancio. Il miglioramento più grande riscontrato è stato che la scrittura in Kotlin ha ridotto del 20%le righe di codice convertite.
Circa la metà dell'app SmartNews è attualmente in Kotlin e il team di sviluppo prevede di scrivere tutte le nuove funzionalità in Kotlin e di eseguire il refactoring di parte del codice esistente per continuare ad aumentare la manutenibilità del codice.
Mentre il team di sviluppo implementava Kotlin e riduceva il codice boilerplate, ha notato un aumento del morale dei team. Il team era entusiasta di poter esprimere le proprie idee in modo più efficiente e di rendere il codice più leggibile in futuro. Nascondio Ohashi, Engineering Manager di SmartNews, ha notato che Kotlin ha contribuito alle sue iniziative di reclutamento dei tecnici. "Le domande più frequenti dei candidati sono
"stai utilizzando Kotlin?" Sembra che ora molti ingegneri siano interessati a migrare a Kotlin e vogliono sostenerlo". Sebbene questi
miglioramenti al morale dei team e all'assunzione non siano stati i motivi principali per cui il team
ha adottato Kotlin, questi cambiamenti positivi aiuteranno l'azienda mentre continua
a crescere in questo settore competitivo.
Inizia
Scopri di più sullo sviluppo di un'app per Android con Kotlin.
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2021-01-06 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2021-01-06 UTC."],[],[],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)."]]