Twitter เห็นว่านักพัฒนาแอปมีประสิทธิภาพมากขึ้นและรวดเร็วยิ่งขึ้นเมื่อใช้ Compose
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Twitter เป็นหนึ่งในแพลตฟอร์มโซเชียลมีเดียที่มีผู้ใช้มากที่สุด
ซึ่งผู้ใช้สามารถดูสิ่งที่เกิดขึ้นในโลกได้ทุกเมื่อ
ทีมวิศวกรเริ่มใช้ Jetpack Compose เพื่อปรับปรุงระบบการออกแบบ
สิ่งที่พวกเขาทำ
เนื่องจากคอมโพเนนต์ UI และระบบการกำหนดธีมของแอป Twitter ได้รับการพัฒนาขึ้นเมื่อประมาณ 10 ปีที่แล้ว และประกอบด้วยคอมโพเนนต์เดิมที่ต้องใช้ความพยายามอย่างมากในการบำรุงรักษา ทีมวิศวกรจึงต้องการสร้างระบบการออกแบบใหม่ที่ปรับขนาดได้ โดยมีคอมโพเนนต์ UI แบบไม่เก็บสถานะที่ใช้งานและบำรุงรักษาง่าย รวมถึงใช้งาน ขยาย และปรับแต่งได้อย่างเป็นธรรมชาติ จึงตัดสินใจใช้ Compose
ทีมเริ่มเปลี่ยนแทนที่ทีละคอมโพเนนต์ผ่านระบบการออกแบบภายใน
และด้วยการนำ Compose มาใช้ในหน้าจอใหม่ที่ไม่ขึ้นอยู่กับการตั้งค่าเดิม
ผลลัพธ์
Compose ตอบโจทย์เป้าหมายในการปรับปรุงความเร็วของนักพัฒนาแอป
ความพึงพอใจของนักพัฒนาแอป และความสามารถในการบำรุงรักษาโค้ด/คอมโพเนนต์ UI ได้อย่างดี หลังจากเริ่มใช้ Compose แล้ว วิศวกรของ Twitter กล่าวว่า "พูดได้คำเดียวว่าน่าทึ่ง
ภายในเราเรียกฟีเจอร์นี้ว่า Android UI 2.0 ซึ่งทำให้การ
กลับไปใช้ระบบ View เดิมเป็นเรื่องยากมาก ซึ่งช่วยเพิ่มประสิทธิภาพและความเร็วในการทำงานที่เราพัฒนาขึ้นมาโดยเฉพาะใน Compose"
โดยพบว่าความเร็วในการพัฒนาและการทดลองดีขึ้น "การเปลี่ยนแปลงการออกแบบสำหรับทุกอย่างที่เรานำมาใช้ใน Compose เร็วกว่าที่เราเคยพบเจอมาก่อนมาก นอกจากนี้ เรายังทำการทดสอบ
อย่างเข้มข้นในการเปลี่ยนแปลงผลิตภัณฑ์ และการทดสอบนี้จะทำได้ดีขึ้นมาก
และรวดเร็วขึ้นเมื่อเขียนด้วย Compose และ Kotlin"
โค้ดที่เขียนไม่เพียงแต่ใช้งานง่ายขึ้นเท่านั้น แต่ยังเขียนได้เร็วขึ้นและอ่านได้ง่ายขึ้นด้วย
"นอกจากนี้ เลเยอร์การกำหนดธีมของเรายังใช้งานง่ายและอ่านได้ง่ายขึ้นมาก
และเราสามารถทำได้ภายในไฟล์ Kotlin ไฟล์เดียว ซึ่งก่อนหน้านี้ต้องใช้ไฟล์ XML หลายไฟล์ที่รับผิดชอบในการกำหนดแอตทริบิวต์และการกำหนดผ่านการวางซ้อนธีมแบบหลายเลเยอร์ การนำโครงสร้างการกำหนดธีมทั้งหมดของเรากลับมาใช้ใหม่ภายในบริบทของ Compose ใช้เวลาเพียงไม่กี่วันถึงสัปดาห์ และพิสูจน์แล้วว่ามีประสิทธิภาพและใช้งานง่ายกว่าระบบธีมเดิมของเรามาก"
เริ่มต้นใช้งาน
ดูข้อมูลเพิ่มเติมเกี่ยวกับฟีเจอร์เขียน
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2021-07-28 UTC
[null,null,["อัปเดตล่าสุด 2021-07-28 UTC"],[],[],null,["[Twitter](https://twitter.com) is one of the most widely used social\nmedia platforms where users can see what's happening in the world at any given\nmoment. The engineering team started using Jetpack Compose to **modernise their\ndesign system.**\n\nWhat they did\n\nBecause the Twitter app's UI components and theming system was developed around\n10 years ago and was comprised of legacy components that required tremendous\nmaintenance efforts, the engineering team wanted to build a new, scalable\ndesign system; with stateless UI components that were easy to use and maintain;\nand intuitive to implement, extend and customize, so they decided to use\nCompose.\n\nThe team started a component-by-component replacement through their internal\ndesign system and by introducing Compose into new screens that don't depend on\ntheir legacy setup.\n\nResults\n\nCompose provided a solid answer to their goal of improving developer velocity,\ndeveloper happiness, and UI code/component maintainability. After starting to\nuse Compose, Twitter engineers say that it's *\"In a word: incredible.\nInternally we refer to it as Android UI 2.0, and it makes it very difficult to\ndelve back into our legacy view system. It has **increased our efficiency and\nvelocity** for things we've developed specifically in Compose.\"*\n\nThey've seen improvements in the speed of development and experimentation: *\"The\n**turn-around on design changes** for anything we've adopted in Compose **is much\nfaster** than we would have experienced previously. Additionally, we experiment\nvery heavily within our product changes, and this is facilitated much better\nand quicker when written in Compose and Kotlin.\"*\n\nThe code they write is not only more intuitive, but also faster to write, and easier to\nread: *\"Additionally, **our theming layer is vastly more intuitive and legible**\nand we've been able to accomplish within a single Kotlin file what otherwise\nextended across multiple XML files that were responsible for attribute\ndefinitions and assignments via multiple layered theme overlays. Reimplementing\nour entire theming structure within the context of Compose took only a matter\nof days to weeks, and has already proven to be much **more robust and intuitive**\nthan our legacy theme system ever has been.\"*\n\nGet started\n\nLearn more about [Compose](/jetpack/compose)."]]