<?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>DEV Community: Andy Delso</title>
    <description>The latest articles on DEV Community by Andy Delso (@ddaypunk).</description>
    <link>https://dev.to/ddaypunk</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%2F86883%2F689becf2-0351-4dcd-b325-2b062fa9a231.jpeg</url>
      <title>DEV Community: Andy Delso</title>
      <link>https://dev.to/ddaypunk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ddaypunk"/>
    <language>en</language>
    <item>
      <title>My Studies of Head First Android Development 3rd Edition: Chapters 5 &amp; 6</title>
      <dc:creator>Andy Delso</dc:creator>
      <pubDate>Wed, 03 Aug 2022 14:23:52 +0000</pubDate>
      <link>https://dev.to/ddaypunk/my-studies-of-head-first-android-development-3rd-edition-ch-5-6-3bfj</link>
      <guid>https://dev.to/ddaypunk/my-studies-of-head-first-android-development-3rd-edition-ch-5-6-3bfj</guid>
      <description>&lt;h1&gt;
  
  
  My studies of Head First Android Development 3rd Edition – Ch 5 &amp;amp; 6
&lt;/h1&gt;

&lt;p&gt;Welcome back to my series on &lt;a href="https://amzn.to/3JoTixn"&gt;&lt;em&gt;Head First Android Development – 3rd Edition&lt;/em&gt;&lt;/a&gt;! This blog post is a continuation of a series of posts I will be doing on reading and working through &lt;em&gt;Head First Android Development&lt;/em&gt;. This blog deals specifically with chapters five and six. &lt;/p&gt;

&lt;p&gt;Are you new to the series? Please start at the beginning of the series &lt;a href="//2022-07-18-my-studies-of-head-first-android-development-3rd-edition-chapters-1-2.md"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: This blog may contain affiliate links for books or products I reference. Clicking on these links may result in compensation.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Let's get a Life-cycle!
&lt;/h1&gt;

&lt;p&gt;The next two chapters deal with some fairly core features of the Android operating system and apps in general:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chapter 5: &lt;em&gt;Being an Activity&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Chapter 6: &lt;em&gt;Finding your way&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Chapter 5
&lt;/h2&gt;

&lt;p&gt;This chapter covers a very important concept of Android called the &lt;strong&gt;activity lifecycle&lt;/strong&gt;. As mentioned in earlier chapters, an activity is a class that control's the app's behavior, which includes buttons in your UI responding to clicks, or what happens when a user enters information into a text view.&lt;/p&gt;

&lt;p&gt;All activities in android apps adhere to a specific lifecycle flow, and this chapter details most of them. Understanding this lifecycle can allow developers to better control behavior in their apps, as well as handle when a user closes the app, or changes its orientation from portrait to landscape (or vice versa).&lt;/p&gt;

&lt;p&gt;The book chooses to illustrate this concept with a stopwatch app, which involved leveraging a new view type I had not seen yet, called a &lt;strong&gt;chronometer view&lt;/strong&gt;. The most significant part about this view is that it has convenience methods for handling time, which made implementing the app much easier. The problem we will need to solve is handling the time when a user leaves the app, which lifecycle methods can help us understand.&lt;/p&gt;

&lt;p&gt;Controlling the lifecycle involves overriding different methods based on the desired outcome.&lt;/p&gt;

&lt;p&gt;Activity lifecycle methods discussed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;onCreate()&lt;/code&gt; - called following activity launch, usually used to display the layout&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onStart()&lt;/code&gt; - called following app made visible&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onResume()&lt;/code&gt; - called after the activity is brought to the foreground again&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onPause()&lt;/code&gt; - called just before the app is not in the foreground&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onStop()&lt;/code&gt; - called before app made invisible&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onRestart()&lt;/code&gt; - called after the activity has been made invisible, and before it is made visible again&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onDestroy()&lt;/code&gt; - called just before activity destroyed&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What about partial invisibility?
&lt;/h3&gt;

&lt;p&gt;The book quickly discusses on a state where the activity is still partially invisible. For example, this will happen when a Google Assistant card pops up. Usually this only covers a portion of the screen, and in this case it's specifically the bottom. For this type of pause, we use the &lt;code&gt;onPause&lt;/code&gt; and &lt;code&gt;onResume&lt;/code&gt; methods, as opposed to the &lt;code&gt;onStop&lt;/code&gt; and &lt;code&gt;onRestart&lt;/code&gt; methods. This is due to the fact that the methods would do the exact same thing, and in the full lifecycle flow, run one after another anyway. To be more specific, &lt;code&gt;onStart&lt;/code&gt; and &lt;code&gt;onRestart&lt;/code&gt; are followed by &lt;code&gt;onResume&lt;/code&gt;, and &lt;code&gt;onStop&lt;/code&gt; is followed by &lt;code&gt;onPause()&lt;/code&gt;. So in this case we can omit the extras, but this is not always true. The book really tries to drive the lifecycle point home with state by state descriptions, including node charts and activities to complete.&lt;/p&gt;

&lt;h3&gt;
  
  
  Saving state to a Bundle
&lt;/h3&gt;

&lt;p&gt;How do we save state when the app is not in focus? Android's simplest option for that is a &lt;strong&gt;Bundle&lt;/strong&gt;. It allows a developer to save the current state, and then retrieve it when the app regains focus.&lt;/p&gt;

&lt;p&gt;With the Chronometer app, most of the work ends up being done in the &lt;code&gt;onStart&lt;/code&gt; and &lt;code&gt;onStop&lt;/code&gt; methods. Within our override of &lt;code&gt;onStop&lt;/code&gt; we need to save the current state to the Bundle. &lt;/p&gt;

&lt;p&gt;This chapter is quite crucial to understanding how an activity works, so I made sure to attempt drawing the diagram from memory a few times for practice.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--asaaXmlr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4262ldu8oua6gg4prduz.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--asaaXmlr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4262ldu8oua6gg4prduz.jpeg" alt="Activity Lifecycle Drawing on Whiteboard" width="800" height="1067"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 6
&lt;/h2&gt;

&lt;p&gt;The next chapter chooses to focus on Fragments, which is another important layer on top of Activities. Fragments, in short, are sort of like sub-activities, and are the way that Android solves apps that require more than one screen without using multiple activities. Instead, we can use a single activity that hosts multiple fragments, and simplify the code using &lt;a href="https://developer.android.com/guide/navigation/"&gt;Android's Jetpack Navigation component&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Fragments have their own lifecycle, similar to Activities, but with more/different optional methods to override, most importantly is &lt;code&gt;onCreateView()&lt;/code&gt;, which executes each time our Fragment layout is needed. Upon further review of the chapter and my notes for it, I noticed they do not include the full fragment lifecycle flow at this point; however, I do remember seeing one later in the book. So we will definitely cover that at a later point!&lt;/p&gt;

&lt;p&gt;Instead, the book continues with a basic setup for a Fragments code, which does resemble an activity. Although, it is called out fairly quickly that a Fragment does not extend an Activity, and defines its own similar methods instead of inheriting them.&lt;/p&gt;

&lt;p&gt;Our main activity layout would end up looking something like this by using the Navigation component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;androidx.fragment.app.FragmentContainerView&lt;/span&gt;  
    &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;  
    &lt;span class="na"&gt;xmlns:app=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res-auto"&lt;/span&gt;  
    &lt;span class="na"&gt;xmlns:tools=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/tools"&lt;/span&gt;  
    &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/nav_host_fragment"&lt;/span&gt;  
    &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;  
    &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;  
    &lt;span class="na"&gt;android:padding=&lt;/span&gt;&lt;span class="s"&gt;"16dp"&lt;/span&gt;  
    &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"androidx.navigation.fragment.NavHostFragment"&lt;/span&gt;  
    &lt;span class="na"&gt;app:navGraph=&lt;/span&gt;&lt;span class="s"&gt;"@navigation/nav_graph"&lt;/span&gt;  
    &lt;span class="na"&gt;app:defaultNavHost=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;  
    &lt;span class="na"&gt;tools:context=&lt;/span&gt;&lt;span class="s"&gt;".MainActivity"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then would override &lt;code&gt;onCreateView()&lt;/code&gt; to correctly inflate the layout for this particular fragment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ExampleFragment&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Fragment&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onCreateView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;  
        &lt;span class="n"&gt;inflater&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;LayoutInflater&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
        &lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ViewGroup&lt;/span&gt;&lt;span class="p"&gt;?,&lt;/span&gt;  
        &lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bundle&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;  
    &lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;fragmentView&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;inflater&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inflate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fragment_welcome&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fragmentView&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once we have the inflated view layout for the fragment, we can wire up a button with a click listener to then navigate to another fragment using :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// within ExampleFragment onCreateView() after fragment layout inflated&lt;/span&gt;
&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;

&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;startButton&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fragmentView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;findViewById&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  

&lt;span class="n"&gt;startButton&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setOnClickListener&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
 &lt;span class="n"&gt;fragmentView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findNavController&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;action_fromFragment_to_toFragment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  My Current feelings on the book overall
&lt;/h2&gt;

&lt;p&gt;I am really enjoying the way this book explains complex concepts. It tends to repeat concepts multiple different ways, designed for how the human brain works. This reminds me of the days I used to work in customer support, and had to explain to non-technical folks what an external IP address is. The variety of activities I have had the chance to work through have certainly helped with retention of the concepts over time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here's to the next chapters!
&lt;/h2&gt;

&lt;p&gt;There is so much more to unpack than I have summarized. Truthfully, you should dive into it yourself! &lt;/p&gt;

&lt;p&gt;I am looking forward to continuing this journey with you all and building more apps as I gain the knowledge I need to become an Android Developer. Next in the series I will be covering Chapter 7 and possibly 8, but I haven't decided yet. As you may have noticed, the posts are getting a bit longer, but I want to keep them a reasonable length. Let me know in the comments if you think they are getting too long!&lt;/p&gt;

&lt;p&gt;What app would you make if you could? After reading this book, I bet you could to it!&lt;/p&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Head First Android Development, 3rd Edition – Dawn Griffiths, David Griffiths&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My Studies of Head First Android Development 3rd Edition: Chapters 3 &amp; 4</title>
      <dc:creator>Andy Delso</dc:creator>
      <pubDate>Wed, 27 Jul 2022 13:42:36 +0000</pubDate>
      <link>https://dev.to/ddaypunk/my-studies-of-head-first-android-development-3rd-edition-ch-3-4-1e91</link>
      <guid>https://dev.to/ddaypunk/my-studies-of-head-first-android-development-3rd-edition-ch-3-4-1e91</guid>
      <description>&lt;p&gt;Welcome back to my series on &lt;a href="https://amzn.to/3JoTixn" rel="noopener noreferrer"&gt;&lt;em&gt;Head First Android Development - 3rd Edition&lt;/em&gt;&lt;/a&gt;! This blog post is a continuation of a series of posts I will be doing on reading and working through &lt;em&gt;Head First Android Development&lt;/em&gt;. This blog deals specifically with chapters three and four. &lt;/p&gt;

&lt;p&gt;Are you new to the series? Please start at the &lt;a href="https://dev.to/ddaypunk/my-studies-of-head-first-android-development-3rd-edition-chapters-1-2-2l1c"&gt;beginning of the series here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: This blog may contain affiliate links for books or products I reference. Clicking on these links may result in compensation.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Things Are Going to Start Getting Interesting! 
&lt;/h2&gt;

&lt;p&gt;In the next two chapters, things start to pick up! Chapters three and four include the following big ideas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deeper dive into Layouts&lt;/li&gt;
&lt;li&gt;A really deep dive into Constraint Layouts

&lt;ul&gt;
&lt;li&gt;Blueprints&lt;/li&gt;
&lt;li&gt;Working with ConstraintLayouts&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Chapter 3
&lt;/h2&gt;

&lt;p&gt;In chapter three, we gain a lot of tools in our tool belt, which sets us up for the meat of Chapter 4 about ConstraintLayouts.&lt;/p&gt;

&lt;p&gt;This chapter goes a bit deeper into a few different layout types, and their general use cases, specifically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LinearLayouts - child views arranged vertically or horizontally&lt;/li&gt;
&lt;li&gt;FrameLayouts - child views stacked&lt;/li&gt;
&lt;li&gt;ScrollViews - use to wrap layouts with a scroll bar&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtdeyivg26necu6xngit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtdeyivg26necu6xngit.png" alt="Linear Layout Example UI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each layout type was nicely presented with a small app example to build. This chapter (as well as previous ones) employs in-text activities to solidify your knowledge. The most memorable (in my opinion) has been the Refrigerator Magnet ones, which allow you to see some of the code and fill in the blanks.&lt;/p&gt;

&lt;p&gt;A big learning point from this chapter was that all layouts extend the View class by extending the ViewGroup class. These layouts require almost all elements in an Android UI to declare their height and width and gain a common API to interact. Also, this is why a developer can nest layouts to create precisely what they need for their app.&lt;/p&gt;

&lt;p&gt;For example, you can have a LinearLayout set to vertical orientation with two child LinearLayouts both set to horizontal orientation to have two rows of elements, but those rows are arranged vertically. Although, in the next chapter we quickly find out that this is not the best way to accomplish the task.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 4
&lt;/h2&gt;

&lt;p&gt;Complex arrangements using nested layouts are not best practice in Android. In this chapter, we learn that these cause Android OS to do more work than it should because each layout and view is turned into an object in the code. &lt;/p&gt;

&lt;p&gt;The solution (and the meat of this chapter) is the ConstraintLayout. I have seen plenty of ConstraintLayout during my initial coursework with Google. In hindsight, I don't know that the course explained it (or the reasoning) as well as the book.&lt;/p&gt;

&lt;p&gt;To teach the reader this concept, the text explains the blueprint view in the Android Studio design editor and the Android Jetpack ecosystem of libraries. Both tools are essential for building a complex UI using ConstraintLayouts.&lt;/p&gt;

&lt;p&gt;Chapter four dives deeply into the many abilities of this layout including&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Constraints&lt;/li&gt;
&lt;li&gt;Bias&lt;/li&gt;
&lt;li&gt;Guidelines&lt;/li&gt;
&lt;li&gt;Barriers&lt;/li&gt;
&lt;li&gt;Chains&lt;/li&gt;
&lt;li&gt;Flows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fefdxn4q2l5sdriyk0iro.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fefdxn4q2l5sdriyk0iro.png" alt="Android Studio design view constraints example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Additionally, this chapter goes into all the relevant Android Studio tools in the Design View to work with ConstraintLayouts. &lt;/p&gt;

&lt;p&gt;Using all of the tools above was quite fun, and I am looking forward to designing and building my apps utilizing them. I am most intrigued by the use of barriers for dynamic resizing of child views that can change the overall layout. I am also interested in chains and flows for proper alignment of elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;androidx.constraintlayout.widget.Barrier&lt;/span&gt;  
 &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/barrier1"&lt;/span&gt;  
 &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;  
 &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;  
 &lt;span class="na"&gt;app:barrierDirection=&lt;/span&gt;&lt;span class="s"&gt;"bottom"&lt;/span&gt;  
 &lt;span class="na"&gt;app:constraint_referenced_ids=&lt;/span&gt;&lt;span class="s"&gt;"editTextTextMultiLine,editTextTextMultiLine2"&lt;/span&gt;  
 &lt;span class="na"&gt;tools:layout_editor_absoluteY=&lt;/span&gt;&lt;span class="s"&gt;"24dp"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;androidx.constraintlayout.helper.widget.Flow&lt;/span&gt;  
 &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/flow"&lt;/span&gt;  
 &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"0dp"&lt;/span&gt;  
 &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;  
 &lt;span class="na"&gt;android:layout_marginTop=&lt;/span&gt;&lt;span class="s"&gt;"24dp"&lt;/span&gt;  
 &lt;span class="na"&gt;app:constraint_referenced_ids=&lt;/span&gt;&lt;span class="s"&gt;"button5,button6,button4,button8,button7,button9"&lt;/span&gt;  
 &lt;span class="na"&gt;app:flow_wrapMode=&lt;/span&gt;&lt;span class="s"&gt;"chain"&lt;/span&gt;  
 &lt;span class="na"&gt;app:layout_constraintEnd_toEndOf=&lt;/span&gt;&lt;span class="s"&gt;"parent"&lt;/span&gt;  
 &lt;span class="na"&gt;app:layout_constraintStart_toStartOf=&lt;/span&gt;&lt;span class="s"&gt;"parent"&lt;/span&gt;  
 &lt;span class="na"&gt;app:layout_constraintTop_toTopOf=&lt;/span&gt;&lt;span class="s"&gt;"parent"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  I’m Only Skimming the Surface on What You Will Find in This Text!
&lt;/h2&gt;

&lt;p&gt;There is so much more to unpack than I have summarized. Truthfully, you should dive into it yourself! &lt;/p&gt;

&lt;p&gt;I am excited to continue with this book and build more apps to gain the knowledge I need to become an Android Developer. Next in the series I will be covering &lt;a href="https://dev.to/ddaypunk/my-studies-of-head-first-android-development-3rd-edition-ch-5-6-3bfj"&gt;chapters five and six&lt;/a&gt;, providing my notes, thoughts, and questions for you.&lt;/p&gt;

&lt;p&gt;What excites you about the prospect of reading it?&lt;/p&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Head First Android Development, 3rd Edition - Dawn Griffiths, David Griffiths&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My Studies of Head First Android Development 3rd Edition: Chapters 1 &amp; 2</title>
      <dc:creator>Andy Delso</dc:creator>
      <pubDate>Tue, 19 Jul 2022 02:18:14 +0000</pubDate>
      <link>https://dev.to/ddaypunk/my-studies-of-head-first-android-development-3rd-edition-chapters-1-2-2l1c</link>
      <guid>https://dev.to/ddaypunk/my-studies-of-head-first-android-development-3rd-edition-chapters-1-2-2l1c</guid>
      <description>&lt;p&gt;For the better part of the past year, I have been working on becoming an Android Developer. As of recently, the effort I have been putting into it, has paid off, but that is for another post. My main issue has been learning consistently and being able to apply the knowledge to real-world applications. Between my day job and parental responsibilities, finding the time to sit down and study is difficult.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: my writings may contain affiliate links for any books or products I reference. Clicking on these links may result in compensation.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Reasoning &amp;amp; Ideas Behind My Studies
&lt;/h2&gt;

&lt;p&gt;At my previous employer, I had set the goal of completing the &lt;a href="https://developer.android.com/courses/android-basics-kotlin/course"&gt;Android Basics in Kotlin&lt;/a&gt; course offered by the Google Development team. Upon completion, I would then work on passing the &lt;a href="https://developers.google.com/certification/associate-android-developer"&gt;Associate Android Developer certification exam&lt;/a&gt;within the year. Unfortunately, I was not fully able reach that goal. &lt;/p&gt;

&lt;p&gt;I did make it through four of the 6 available units before the end of 2021 while balancing my work and personal life. Although this was difficult, I intentionally built time into my work day to make it happen because this was a work-related goal. It was also a big part of my personal development plan there.&lt;/p&gt;

&lt;p&gt;Due to this on-and-off learning being an ineffective way to learn, I decided to take it a bit more seriously this year. So I have started to study Android for at least one hour every morning after working out. As it had been a few months since taking a break from the course, I knew I needed some review to tackle units 5 and 6 and the certification exam.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dive Into Head First Android Development - 3rd Edition With Me
&lt;/h2&gt;

&lt;p&gt;Personally I have enjoyed the first few chapters of &lt;a href="https://amzn.to/3Kvqh4d"&gt;Head First Design Patterns - 2nd Edition&lt;/a&gt; for both the first and second editions. So I thought I would give the newest edition of &lt;a href="https://amzn.to/3JoTixn"&gt;&lt;em&gt;Head First Android Development&lt;/em&gt;&lt;/a&gt; a go.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclaimer: If you have not programmed before (or worked in Kotlin), I recommend looking into another book or set of lessons first. Since I am talking about Head First, the book recommends looking at &lt;a href="https://amzn.to/3LY1ZQC"&gt;Head First Kotlin - 1st Edition&lt;/a&gt; to get your feet wet with the language. I also would recommend taking a look at interactive courses like &lt;a href="https://hyperskill.org/tracks/18"&gt;JetBrains Academy - Kotlin Basics&lt;/a&gt;. I enjoyed how it allowed you to try and skip sections familiar to you. Additionally, I enjoyed the integration with JetBrain's IDEs, such as Android Studio.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My Note-Taking Process
&lt;/h2&gt;

&lt;p&gt;I have recently started using &lt;a href="https://obsidian.md"&gt;Obsidian.md&lt;/a&gt; to take notes alongside these blog posts. Obsidian.md is a nifty and fully featured note app. It is marketed as "a second brain, for you, forever" and described as a &lt;em&gt;powerful knowledge base (read: wiki) on top of a local folder of plain Markdown files&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The selling point for me, and probably for the privacy concerned, is that your data is stored locally! For those interested in the app, I used &lt;a href="https://www.youtube.com/watch?v=QgbLb6QCK88&amp;amp;list=PL3NaIVgSlAVLHty1-NuvPa9V0b0UwbzBd"&gt;this playlist&lt;/a&gt; to learn the basics, and I was able to start navigating it quickly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Dive in!
&lt;/h2&gt;

&lt;p&gt;The first two chapters have been fairly easy for me (given my working knowledge of Android and Kotlin). These chapters include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chapter 1: &lt;em&gt;Getting Started: Diving In&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Chapter 2: &lt;em&gt;Building Interactive Apps: Apps That Do Something&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Chapter 1
&lt;/h2&gt;

&lt;p&gt;The initial "dive-in" covers an introduction to &lt;a href="https://developer.android.com/studio"&gt;Android Studio&lt;/a&gt; IDE (Integrated Development Environment) and how to setup a basic app. I have been using this application for a while, so this chapter went fairly fast for me. In fact, I had already set it up on my MacBook Pro before receiving the book in the mail.&lt;/p&gt;

&lt;p&gt;This chapter will give folks new to Android development a thorough walk-through of setting up the IDE. The chapter also includes an overview of where to find things you need within the first few chapters. The first chapter also gives the reader a brief introduction to the Android API ecosystem and some basic concepts like layouts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 2
&lt;/h2&gt;

&lt;p&gt;The second chapter digs into making something I find interesting, a beer listing app. It features good introductions to layouts, UI component views, activities, and resources. This chapter has you build an app with a beer color &lt;code&gt;Spinner&lt;/code&gt; (drop-down), connected to a Button, when pressed, generates a list of appropriate beers below.&lt;/p&gt;

&lt;p&gt;The walkthrough of this build is very introductory and explains what it is doing multiple times to drive the concepts home. This method is central to the whole Head First series style. It desires to teach you about thinking (metacognition) and how to learn better, given their studies on how the human brain learns.&lt;/p&gt;

&lt;p&gt;Completing the app was not too bad with my pre-existing knowledge, but it solidified my basic knowledge about Android as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All UI elements extend the View class. To elaborate, this means &lt;code&gt;Button&lt;/code&gt; and &lt;code&gt;Spinner&lt;/code&gt; are Views, and all share common attributes and methods. &lt;code&gt;TextView&lt;/code&gt; was just obvious... 😁&lt;/li&gt;
&lt;li&gt;Placing strings in to a resource file is a forward thinking habit for localization practices.&lt;/li&gt;
&lt;li&gt;Your resource file can also include arrays of strings that Spinners can consume for listing things.&lt;/li&gt;
&lt;li&gt;Android methods like &lt;code&gt;findViewById()&lt;/code&gt; and &lt;code&gt;setOnClickListener()&lt;/code&gt; are essential code building-blocks for successful apps.&lt;/li&gt;
&lt;li&gt;Using the above methods, we can locate elements and respond to actions on them, then update the UI by setting other elements' attributes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, I am excited to be back into learning Android development! I hope this helps you become excited to start learning (if you haven't yet). The Head First series learning style speaks in a way that makes learning easy for me. It may not be for everyone, but if you haven't tried it, I think you should give it a go!&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow Along on My Blog Series Regarding Head First Android Development: 3rd Edition
&lt;/h2&gt;

&lt;p&gt;Have you found my review of the first two chapters of Head First Android Development: 3rd Edition helpful? If so, check out my &lt;a href="https://dev.to/ddaypunk/my-studies-of-head-first-android-development-3rd-edition-ch-3-4-1e91"&gt;next blog featuring chapters three and four&lt;/a&gt; and what lessons I learned from them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Head First Android Development, 3rd Edition - Dawn Griffiths, David Griffiths&lt;/em&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>mobile</category>
      <category>book</category>
    </item>
    <item>
      <title>Using a Component Model in Selenium to Increase Maintainability and Reusability</title>
      <dc:creator>Andy Delso</dc:creator>
      <pubDate>Mon, 17 Jun 2019 15:49:31 +0000</pubDate>
      <link>https://dev.to/ddaypunk/how-we-use-a-component-model-in-selenium-to-increase-maintainability-1nk0</link>
      <guid>https://dev.to/ddaypunk/how-we-use-a-component-model-in-selenium-to-increase-maintainability-1nk0</guid>
      <description>&lt;p&gt;Over the past 9 years of &lt;a href="https://sproutsocial.com" rel="noopener noreferrer"&gt;Sprout Social's&lt;/a&gt; existence,  our &lt;a href="https://www.seleniumhq.org/" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; framework has grown into 100's of scenarios with as many page classes and factory containers. We've noticed it has become cumbersome to manage and as such, our QA Engineers thought the models in use needed a refresh. So in recent times, we adopted what we like to call the &lt;strong&gt;Component Model&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: All code examples can be found in the following &lt;a href="https://gist.github.com/andydelso/4f3e62d4b049cf2aa460e3155e2aa099" rel="noopener noreferrer"&gt;Github Gist&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The idea for this component model was a result of a few things: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modern websites aren't really built strictly of static "pages" any more&lt;/li&gt;
&lt;li&gt;A Grow@Sprout talk on the &lt;a href="https://medium.com/@dhkelmendi/solid-principles-made-easy-67b1246bcdf" rel="noopener noreferrer"&gt;SOLID principles&lt;/a&gt; by Uncle Bob&lt;/li&gt;
&lt;li&gt;Our web app’s use of &lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React.js&lt;/a&gt;, which uses a similar idea of components for encapsulation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Modern websites (i.e. web applications) are highly dynamic pieces of software with global bars, side bars, content views, and pop-outs. Many of these pieces are yet composed of other smaller pieces. Reflecting on this and the SOLID principles, we realized that the monolithic classes the page-object model created were not working to our advantage anymore. &lt;/p&gt;

&lt;p&gt;We noticed we had multiple functional zones and really only one spot for actual page content. We had a global top nav bar that also included settings access. Additionally, there is a secondary left nav bar for navigating within functional areas. A lot of pages also contained a rail on the right side commonly housing date pickers and filters for the content view. Please refer to the mockup below to help visualize this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F220et6nvr9sr5d3gwzu4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F220et6nvr9sr5d3gwzu4.png" width="630" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We noticed plenty of areas in the framework where we could &lt;a href="https://www.codeproject.com/Articles/36712/SOLID-and-DRY" rel="noopener noreferrer"&gt;DRY (Don’t Repeat Yourself)&lt;/a&gt; up the code. This is included in the SOLID software development principles. Buttons, inputs, and data visualizations all share common code in the UI implementation. Why, then, should our tests implement multiple ways to get and interact with filters across multiple page classes? &lt;/p&gt;

&lt;p&gt;Instead, we agreed that the components our selenium tests use should be a 1:1 representation of their equivalent web UI component. Take this example &lt;a href="https://gist.github.com/andydelso/4f3e62d4b049cf2aa460e3155e2aa099#file-checkboxv1-java" rel="noopener noreferrer"&gt;CheckboxV1&lt;/a&gt; (click for the gist code snippet) class. The most beneficial aspects of this model are: the component houses its unique selenium selector, and specific constructors and methods that your tests can consume. This significantly enhances the readability of code and the maintainability of the framework.&lt;/p&gt;

&lt;p&gt;After using these components for a while, we started to notice that code was being repeated between classes. In order to &lt;em&gt;DRY&lt;/em&gt; the repetition up, we created a class called &lt;a href="https://gist.github.com/andydelso/4f3e62d4b049cf2aa460e3155e2aa099?ts=4#file-basecomponent-java" rel="noopener noreferrer"&gt;BaseComponent&lt;/a&gt; to control much of the basic behavior of any component. One can then extend all other components from this BaseComponent to ensure every component implementation is as simple as possible.&lt;/p&gt;

&lt;p&gt;Combining implementation from our original &lt;strong&gt;CheckboxV1&lt;/strong&gt; with &lt;strong&gt;inheritance from BaseComponent&lt;/strong&gt; further simplifies the component and increases the maintainability of the framework. &lt;a href="https://gist.github.com/andydelso/4f3e62d4b049cf2aa460e3155e2aa099?ts=4#file-checkboxv2-java" rel="noopener noreferrer"&gt;CheckboxV2&lt;/a&gt; allows BaseComponent to do most of the heavy lifting not specific to the particular component. We also have one less spot to check when fixing issues as most of the behavior is within BaseComponent instead of multiple versions of similar functionality scattered across multiple components.&lt;/p&gt;

&lt;p&gt;A quick note on the above &lt;strong&gt;CheckboxV2&lt;/strong&gt; implementation - we tend to use the String argument constructor the most with components that have attributes in the UI code. The &lt;em&gt;By&lt;/em&gt; and &lt;em&gt;WebElement&lt;/em&gt; argument constructors are backups for elements in our UI that might not contain special data attributes, what we refer to as QA attributes, but the follow same/similar component structure in the DOM. However, we encourage our team to add their own QA selectors if able to or further collaborate with the developers to get them added. Having them usually allows the component code and subsequent Selenium automation to be much simpler overall.&lt;/p&gt;

&lt;p&gt;Here is a quick example of how we then use the components within a &lt;a href="https://gist.github.com/andydelso/4f3e62d4b049cf2aa460e3155e2aa099?ts=4#file-page-java" rel="noopener noreferrer"&gt;Page&lt;/a&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;a href="https://gist.github.com/andydelso/4f3e62d4b049cf2aa460e3155e2aa099?ts=4#file-checkboxsteps-java" rel="noopener noreferrer"&gt;Step Definition&lt;/a&gt; classes.&lt;/p&gt;

&lt;p&gt;It has been a fun and interesting journey getting to this point through many refactors of our framework. However, it has proved time and time again to make our framework a bit easier to grok as well as maintain. We are already beginning to think of ways to improve upon this further such as with a wrapper class called &lt;em&gt;Selector&lt;/em&gt; to help with formatting and making BaseComponent more friendly to work with. We look forward to providing more information on those in the future&lt;/p&gt;

&lt;p&gt;Have you or your organization used or are currently using something similar? Please share your experiences in the comments!&lt;/p&gt;

</description>
      <category>selenium</category>
      <category>automation</category>
      <category>testing</category>
      <category>maintainability</category>
    </item>
  </channel>
</rss>
