<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Musyoka Muasya</title>
    <description>The latest articles on Forem by Musyoka Muasya (@joeciox).</description>
    <link>https://forem.com/joeciox</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1021281%2F0921b719-03c2-48e6-9d64-4f5383ee1599.jpg</url>
      <title>Forem: Musyoka Muasya</title>
      <link>https://forem.com/joeciox</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/joeciox"/>
    <language>en</language>
    <item>
      <title>Jetpack Compose Hands-on Practice: My Journey Part 2</title>
      <dc:creator>Musyoka Muasya</dc:creator>
      <pubDate>Fri, 17 Feb 2023 09:07:40 +0000</pubDate>
      <link>https://forem.com/joeciox/jetpack-compose-hands-on-practice-my-journey-part-2-1chn</link>
      <guid>https://forem.com/joeciox/jetpack-compose-hands-on-practice-my-journey-part-2-1chn</guid>
      <description>&lt;p&gt;In this article, I will explain my first hands-on experience with Jetpack Compose. It builds on my &lt;a href="https://medium.com/@musyokamuasya/getting-started-with-jetpack-compose-my-journey-6df29d886816"&gt;previous article &lt;/a&gt;where I explored the theory behind Compose.&lt;/p&gt;

&lt;p&gt;The hands-on practice has three parts&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;GitHub&lt;/li&gt;
&lt;li&gt;Code labs&lt;/li&gt;
&lt;li&gt;Project&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  GitHub
&lt;/h2&gt;

&lt;p&gt;I read through tons of code to see whether I understood and could pick the patterns. I have been building on Android with Kotlin, and I could understand most parts, though I could not replicate them. Reading code samples helps me see how other developers implement features, and I also understand the common patterns I need to focus on.&lt;/p&gt;

&lt;p&gt;Google learn Github has code samples where you learn the recommended way of building apps. &lt;a href="https://github.com/android/compose-samples"&gt;https://github.com/android/compose-samples&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Codelabs
&lt;/h2&gt;

&lt;p&gt;Codelabs are short guided tutorials on implementing a feature, library, or concept. They have a step-by-step, hands-on guide coding experience where you are guided to implement the feature. I have been using codelabs for foundational knowledge of new features. &lt;/p&gt;

&lt;p&gt;Below are the codelabs I used to gain practical hands-on experience with Compose. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;a href="https://developer.android.com/codelabs/jetpack-compose-basics?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fjetpack-compose-for-android-developers-1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fjetpack-compose-basics"&gt;Jetpack Compose basics&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In this codelab, I had my first real hands-on experience with Compose. I also had a broader overview of Compose. It has basic concepts such as &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setting up a Compose application - here, you start a new compose application, set up the dependencies and build your application. I recommend using Bill of Materials since it makes dependencies easily manageable. Also, do not download the solution code yet. It is better to follow the step-by-step guide. When you encounter a blocker, check the cause and find a solution online.&lt;/li&gt;
&lt;li&gt;Declaring and calling composable functions&lt;/li&gt;
&lt;li&gt;Using the default app theme and creating a design preview.&lt;/li&gt;
&lt;li&gt;Hands-on with basic building blogs like text, images, row, column, box, list and modifier.&lt;/li&gt;
&lt;li&gt;Grasp of state, state hoisting and persistence.&lt;/li&gt;
&lt;li&gt;Animations and theme - In this section, you change the default theme to your desired theme.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is no catch in this codelab. It was my first hands-on, and I enjoyed seeing the design come to life. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;a href="https://developer.android.com/codelabs/jetpack-compose-layouts?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fjetpack-compose-for-android-developers-1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fjetpack-compose-layouts"&gt;Basic layouts in Compose&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In this codelab, I learned more about designing UI elements. A deep understanding of layouts is critical in Compose. They help you replicate UI designs, foundational to a great user experience. You also learn how to follow the material design recommendations in Compose.&lt;/p&gt;

&lt;p&gt;In this article, I learned the designing process using Compose. I took time to work with the common UI elements. One way to gain from this codelab is to take time and explore how to design other components. I use &lt;a href="http://dribbble.com"&gt;dribbble.com&lt;/a&gt; and &lt;a href="http://behance.net"&gt;behance.net&lt;/a&gt; for design inspirations. &lt;/p&gt;

&lt;p&gt;Some of the components I learned through the codelab are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TextField and associated TextFieldDefaults.&lt;/li&gt;
&lt;li&gt;Designing normal text.&lt;/li&gt;
&lt;li&gt;Importing and using Icons.&lt;/li&gt;
&lt;li&gt;Aligning content in row, column and box.&lt;/li&gt;
&lt;li&gt;Handling collections and scrolling through them.&lt;/li&gt;
&lt;li&gt;Slot API - handles different sections with a similar pattern.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;a href="https://developer.android.com/codelabs/jetpack-compose-state?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fjetpack-compose-for-android-developers-1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fjetpack-compose-state"&gt;State in Jetpack Compose&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In this codelab, I learned how to handle dynamic data and behavior in Compose. Compose uses state and events extensively to display elements on the screen. In this codelab, I learned&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to think about state and events.&lt;/li&gt;
&lt;li&gt;The practical difference between stateless and stateful composables.&lt;/li&gt;
&lt;li&gt;How to hoist state and the recommended practice in hoisting&lt;/li&gt;
&lt;li&gt;Persisting state using remember and rememberSaveable&lt;/li&gt;
&lt;li&gt;Using ViewModel as state holder for Compose&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I had to refresh on some concepts of state, lifecycle, and state hoisting theory. State is another important concept in Compose. You need to spend time and ensure you understand how to handle state and events as other concepts in android build on them.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;a href="https://developer.android.com/codelabs/jetpack-compose-advanced-state-side-effects?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fjetpack-compose-for-android-developers-3%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fjetpack-compose-advanced-state-side-effects"&gt;Advanced State and Side Effects in Jetpack Compose&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;After the first state codelab, I found this codelab useful. It builds upon knowledge from the first state codelab. In this codelab, you will learn advanced concepts in handling state in Compose. &lt;/p&gt;

&lt;p&gt;Some of the concepts I learned in this codelab are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create state holders beyond ViewModels.&lt;/li&gt;
&lt;li&gt;Streaming data from state holders like ViewModel using Livedata, RxJava2, and Flow&lt;/li&gt;
&lt;li&gt;Side effects using rememberUpdatedState, productState, LaunchedEffect and DisposableEffect&lt;/li&gt;
&lt;li&gt;Using Coroutines in Compose.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The concepts in this codelab are quite advanced. I was frequently searching for how to implement most parts. I prefer reading over watching, so I read several articles, especially at &lt;a href="https://proandroiddev.com/"&gt;https://proandroiddev.com/&lt;/a&gt; and &lt;a href="https://www.kodeco.com/"&gt;https://www.kodeco.com/&lt;/a&gt;. Like many concepts in programming, it gets better with practice.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;a href="https://developer.android.com/codelabs/jetpack-compose-navigation?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fjetpack-compose-for-android-developers-3%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fjetpack-compose-navigation"&gt;Jetpack Compose Navigation&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Navigation was my next challenge after state. &lt;/p&gt;

&lt;p&gt;The key concepts I learned from the codelab are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating routes for navigation destinations&lt;/li&gt;
&lt;li&gt;Creating a navigation graph and connecting it with NavHost&lt;/li&gt;
&lt;li&gt;Enabling common navigation host&lt;/li&gt;
&lt;li&gt;Building, triggering, and verifying deep links&lt;/li&gt;
&lt;li&gt;Navigation with arguments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://developer.android.com/codelabs/jetpack-compose-testing?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fjetpack-compose-for-android-developers-4%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fjetpack-compose-testing"&gt;Testing in Jetpack Compose&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In this codelab, I learned how to test UIs created using Compose. I combined this codelab with the last part of Compose Navigation which tests navigation. I learned&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unit testing UI elements&lt;/li&gt;
&lt;li&gt;Using Test Driven Development in Compose&lt;/li&gt;
&lt;li&gt;Using semantics tree in Compose tests&lt;/li&gt;
&lt;li&gt;Merging semantics trees&lt;/li&gt;
&lt;li&gt;Synchronizing tests and subjects under test&lt;/li&gt;
&lt;li&gt;Testing Navigation components&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The codelab is not exhaustive on all tests you can perform in compose. However, it offers solid foundation on testing in Compose. To learn more on Compose test, kindly check Compose cheat sheet &lt;a href="https://developer.android.com/jetpack/compose/testing-cheatsheet"&gt;https://developer.android.com/jetpack/compose/testing-cheatsheet&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Project
&lt;/h2&gt;

&lt;p&gt;The end goal of learning Compose was to build projects. With practical knowledge in layouts, state, navigation, and testing, I had a foundation to build a project with Compose. I could learn other concepts like animations, theming, and accessibility as I built the project. &lt;/p&gt;

&lt;p&gt;I chose to rebuild one of my side projects in Compose. You can get design inspirations at &lt;a href="http://behance.net"&gt;behance.net&lt;/a&gt; and &lt;a href="http://dribbble.com"&gt;dribbble.com&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Learning a new technology can be boring and time intensive. Learning Compose is an iterative process and some concepts like state management may not come easy. However, concepts will become clearer and you will be building faster.&lt;/p&gt;

</description>
      <category>android</category>
      <category>mobile</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Getting Started with Jetpack Compose: My Journey</title>
      <dc:creator>Musyoka Muasya</dc:creator>
      <pubDate>Tue, 14 Feb 2023 09:30:20 +0000</pubDate>
      <link>https://forem.com/joeciox/getting-started-with-jetpack-compose-my-journey-16cg</link>
      <guid>https://forem.com/joeciox/getting-started-with-jetpack-compose-my-journey-16cg</guid>
      <description>&lt;p&gt;In this article, I will explain how I got started with Compose.&lt;/p&gt;

&lt;p&gt;I was interviewing with a company I admire, and I missed the opportunity because they wanted someone proficient with Compose as they are migrating their tech stack from View-based UI to Compose.&lt;/p&gt;

&lt;p&gt;If you are looking for opportunities, learning Compose may make you stand out because several companies are migrating their tech stack to Compose.&lt;/p&gt;

&lt;p&gt;So, at the start of the year, I challenged myself to learn Compose. I will document my learning process below.&lt;/p&gt;

&lt;p&gt;I started by reading the official documentation. That is where I start for a new technology or framework. As I read through the it, I understand the philosophy behind the technology or framework. I may take notes on important concepts or the whole framework.&lt;/p&gt;

&lt;p&gt;In Compose, I skimmed through the whole documentation. I took notes on key areas.&lt;/p&gt;

&lt;p&gt;After going through the primary documentation, I focused on key foundational areas. I started with the first article, ‘&lt;a href="https://developer.android.com/jetpack/compose/mental-model"&gt;Thinking in compose.&lt;/a&gt;’ I recommend starting with this article. It gives you a mental overview of how the Compose works.&lt;/p&gt;

&lt;p&gt;Later, I separated the remaining concepts into three classes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Working with static data&lt;/li&gt;
&lt;li&gt;Working with dynamic data&lt;/li&gt;
&lt;li&gt;Testing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Working with static data
&lt;/h2&gt;

&lt;p&gt;This section focuses on how to make the composables. I wanted to learn how to make the composables and style them to make beautiful UI. The two articles I read are&lt;br&gt;
 -&lt;a href="https://developer.android.com/jetpack/compose/layouts"&gt;Components&lt;/a&gt; - components are the building blocks in Compose, such as text, lists, and graphics. Components are the first place I started learning about Compose. Articles on components are in the design section. I learned how to handle text, graphics, and lists. I learned how to place items in Column, Row, and Box.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://developer.android.com/jetpack/compose/modifiers"&gt;Modifiers&lt;/a&gt; - modifiers help style components. They describe how the component looks, such as padding. They also describe how components behave, such as making components clickable. I learned modifiers to make components look and behave as I desired.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Working with Dynamic Data
&lt;/h2&gt;

&lt;p&gt;In this section, I wanted to learn how to work with the state. The general definition of the state is any value that changes with time.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://developer.android.com/jetpack/compose/state"&gt;Managing State&lt;/a&gt; One of the main differences between composables and view-based UI how they handle dynamic data. When values in the Compose change, the composable whose values have changed is redrawn with new values. Some key concepts I learned are a deeper explanation of state, working with immutable data, stateful and stateless composables, state hoisting, and state holders. State in UI is a new concept in Android. The concepts were not straightforward, so I am still learning.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.android.com/jetpack/compose/lifecycle"&gt;Lifecycle and Phases in Compose&lt;/a&gt; lifecycle in Android is how components in Android behave under certain circumstances. Lifecycle in Compose explains how composables behave before, during, and after recomposition. The phases helped me understand how composition happens. The three phases are composition, layout, and drawing.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.android.com/jetpack/compose/side-effects"&gt;Side Effects&lt;/a&gt;the article on side effects explains how a change in a composable may affect other components outside the composable scope. Typically, composables should be free of side effects. However, in some scenarios, side effects are necessary. I learned how to decide when to have side effects and how to avoid side effects when they are harmful.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;Jetpack Compose ships with tools for testing UI components. Testing composables is different from testing views. The main difference is in view-based U you describe the UI element but Compose emits UI elements. I focused on compose specific testing libraries like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Semantics&lt;/li&gt;
&lt;li&gt;ComposeTestRule&lt;/li&gt;
&lt;li&gt;Finders&lt;/li&gt;
&lt;li&gt;Assertions&lt;/li&gt;
&lt;li&gt;Actions&lt;/li&gt;
&lt;li&gt;Synchronization&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Additional Readings
&lt;/h2&gt;

&lt;p&gt;Additional readings are materials I used for reference when learning foundational concepts in Compose.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://developer.android.com/jetpack/compose/kotlin"&gt;Kotlin for Jetpack Compose&lt;/a&gt; - Here, I learned some Kotlin language semantics, making it easy to write composables. I refreshed on higher-order functions, default arguments, lambda expressions, trailing lambdas, destructuring, and coroutines.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.android.com/jetpack/compose/performance"&gt;Performance&lt;/a&gt; — learn how to optimize the application.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.android.com/jetpack/compose/architecture"&gt;Architecture&lt;/a&gt; - learned the unidirectional data flow, where composables accept state and expose events.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next article I will write on the hands-on learning.&lt;/p&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
