<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mikael Svensson on Medium]]></title>
        <description><![CDATA[Stories by Mikael Svensson on Medium]]></description>
        <link>https://medium.com/@mikael.svensson?source=rss-376e5465716f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ElyTC5wTtkRfOI0w.</url>
            <title>Stories by Mikael Svensson on Medium</title>
            <link>https://medium.com/@mikael.svensson?source=rss-376e5465716f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 08:17:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mikael.svensson/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How we publish the Klarna Point of Sale app, Part 5/5]]></title>
            <link>https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-5-5-6ca5c2aa14b1?source=rss-376e5465716f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ca5c2aa14b1</guid>
            <category><![CDATA[google-play-store]]></category>
            <category><![CDATA[appcenter]]></category>
            <category><![CDATA[app-store]]></category>
            <category><![CDATA[deployment-pipelines]]></category>
            <dc:creator><![CDATA[Mikael Svensson]]></dc:creator>
            <pubDate>Fri, 20 Aug 2021 10:06:03 GMT</pubDate>
            <atom:updated>2021-08-25T14:56:47.423Z</atom:updated>
            <content:encoded><![CDATA[<p>Distributing it to Apple App Store and Google Play.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_nE_Qxk0660r3Ow8MaavvQ.jpeg" /><figcaption>The store manager by the window knows that their feature requests are rolled out with ease.</figcaption></figure><h3>TL;DR</h3><ul><li>It’s smart to pause the pipeline to allow a product manager to confirm each release.</li><li>App Center doesn’t completely automate the process. You still need to “promote” the release in App Store and Google Play.</li></ul><h3>Two-step Process To Distribute App</h3><p>To release your app to Apple App Store and Google Play you need to two two things: Create a release and distribute the release.</p><p><em>More on that in a sec, but first a quick sidetrack…</em></p><h3>Quick sidetrack: Release notes and Go/No-Go</h3><p>When the pipeline is triggered on every commit to the master branch it is usually important to <em>not automatically</em> distribute the resulting build to Google Play and App Store. You probably don’t want to bother your users with updates to the app more than, say, once per week (and you probably merge feature branches to master more often than that).</p><p>You want to explicitly decide if a certain build should be released or not. Luckily, Jenkins has a very nice feature for this: input steps which pauses the pipeline until a human makes a decision.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4834cad28f3489d1d4374a25e2a7cf01/href">https://medium.com/media/4834cad28f3489d1d4374a25e2a7cf01/href</a></iframe><p>The above snippet will pause the pipeline/job for 24 hours and:</p><ul><li>allow someone to write some release notes which will be sent to the app stores along with the app,</li><li>allow someone to click <em>Yes</em> to confirm that this build should indeed be released to app stores.</li></ul><p>This accomplishes two important things:</p><ol><li>The build pipeline is paused until someone explicitly clicks the button “Yes, release to production”. This ensures that you never “accidentally” release something to production.</li><li>You get a nice way of supplying release notes. The above code example would store the input, i.e. the release notes, in a variable called releaseNotes.</li></ol><p>This means that the build is paused at this point until someone looks at the build’s console in Jenkins and clicks the “Yes, release to production” button.</p><p>The release notes will show up under the <em>What’s New</em> section in Apple’s App Store, so phrasing the release notes in a positive way is a good idea since people interested in downloading your app will see them.</p><p>Note: The pipeline/job will be aborted if no one clicks Yes within 24 hours.</p><p>Note:</p><p>After confirming that we want the app to be release we move on to actually distributing the app to Apple App Store and Google Play.</p><p><em>Now back to the main topic of this post…</em></p><h3>Two-step process to release through App Center</h3><p>App Center distributes your app in two steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMKeWNVbsAn_QPOf7Q4fXw.png" /><figcaption>Clicking on the Distribute button for a build is manual work. Let’s automate it!</figcaption></figure><ol><li>Invoke the Distribute action on a Build. This initiates the creation of a “release”.</li><li>Once the “release” has been created you can “distribute” it to different “destinations”, like app stores or groups of users. Setting up destination Stores and Groups are one-time tasks and automating it might not be worth the effort (which is why it’s not covered in this blog post).</li></ol><figure><img alt="This is where you access and create your releases, and destinations like user groups and app stores." src="https://cdn-images-1.medium.com/max/560/1*uN0LLkDF6HlvBDyN1hluHQ.png" /><figcaption>This is where you access and create your releases, and destinations like user groups and app stores.</figcaption></figure><h4>First step: Start distributing a build</h4><p>Ok. Let’s automate step 1: Triggering the Distribute action in your Jenkinsfile. It’s pretty much a single curl call:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87672ba321a033ef23b818b4ee295c2e/href">https://medium.com/media/87672ba321a033ef23b818b4ee295c2e/href</a></iframe><p>Note that BUILDID would get its value from earlier steps in your CI/CD pipeline. You would get it from the result of the POST to<br>​/v0.1​/apps​/{owner_name}​/{app_name}​/branches​/{branch}​/builds you did to compile the app.</p><p>The DISTRIBUTIONID requires a bit of explanation: It is an UUID identifying the “user group” or the app store to which you want to distribute the app (see earlier screenshot).</p><p>You need to GET /v0.1​/apps​/{owner_name}​/{app_name}​/distribution_stores and then find the UUID for the distribution (group or app store) you are interested in. You can make that call once with curl, find the UUID and hardcode it as your DISTRIBUTIONID value.</p><p>Or you can automate it… This Groovy script uses curl and jq to look for a distribution called “Production” and return its UUID:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a9a3a3cbe79079f771e47086181a1a2/href">https://medium.com/media/8a9a3a3cbe79079f771e47086181a1a2/href</a></iframe><p>After you’ve triggered the distribution you need to wait for the release to first be created and then to be completed.</p><h4>Second step: Promote the release</h4><p>App Center will push your final app to both App Store and Google Play but you still need to manually log in to the stores to “submit the new version for review” (App Store) or “promote to production” (Google Play).</p><p>These additional steps in the admin interfaces for the two app stores bring up an interesting point about deployment automation of native apps: <em>You cannot automate it fully</em>. Kind of. Your options are very limited with Apple and it is hard to automate full process. You have more options when it comes to Google and if you really want to automate the whole process, including automatically releasing your app to all your users, you should take a look at Google’s <a href="https://developers.google.com/android-publisher/tracks">Tracks documentation</a>.</p><p>That being said, automating everything is probably not a good idea since you will probably want some kind of go/no-go step at the end anyway. Just to be sure you’ve dotted all the i’s and crossed all the t’s.</p><p><strong>After the app stores processes are complete you finally have the latest version of your app released to your users. It was a long process but now it’s done.</strong></p><h3>The next steps</h3><p>Time to start working on the next release :-)</p><p>Previous posts:<br>Blog post 1/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-1-5-3c3bf556a65b">Why automate?</a><br>Blog post 2/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-2-5-78ec48525eae">How does Jenkins orchestrate the process?</a><br>Blog post 3/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-3-5-8c390d8982f2">How is App Center configured?</a><br>Blog post 4/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-4-5-f3d4f05b08c8">How to run tests in Browserstack?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ca5c2aa14b1" width="1" height="1" alt=""><hr><p><a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-5-5-6ca5c2aa14b1">How we publish the Klarna Point of Sale app, Part 5/5</a> was originally published in <a href="https://engineering.klarna.com/">Klarna Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we publish the Klarna Point of Sale app, Part 4/5]]></title>
            <link>https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-4-5-f3d4f05b08c8?source=rss-376e5465716f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3d4f05b08c8</guid>
            <category><![CDATA[app-testing]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[browserstack]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[appcenter]]></category>
            <dc:creator><![CDATA[Mikael Svensson]]></dc:creator>
            <pubDate>Mon, 09 Aug 2021 11:16:05 GMT</pubDate>
            <atom:updated>2021-08-25T14:56:55.010Z</atom:updated>
            <content:encoded><![CDATA[<p>Testing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_nE_Qxk0660r3Ow8MaavvQ.jpeg" /><figcaption>The customer in green trusts that the point-of-sale system has been thoroughly tested.</figcaption></figure><h3>Writing tests</h3><p>We chose to write our tests in Javascript, using the Jest testing framework, and controlling the app using the Appium. We could have written our tests in other languages as well but since we use Javascript for the app itself it made sense to us to also use Javascript when implementing the tests.</p><p>Just a quick technology check:</p><ul><li><a href="https://jestjs.io/">Jest</a>: Test framework for Javascript.</li><li>Selenium: Tool for controlling web browsers.</li><li><a href="http://appium.io/docs/en/about-appium/intro/">Appium</a>: Tool for controlling mobile apps.</li><li>Webdriver: Wire protocol used by both Selenium and Appium.</li><li><a href="https://www.browserstack.com/app-automate">Browserstack App Automate</a>: Cloud service offering real devices which can be controlled remotely using Appium.</li></ul><p>Confused about the difference between Appium and Selenium? Reading Mindfire’s article on <a href="http://www.mindfiresolutions.com/blog/2018/05/selenium-vs-appium/">Selenium vs Appium</a> might clear up some things.</p><h3>Why testing using a cloud service like Browserstack?</h3><p>You want to be sure that your app works on a number of devices, both iOS devices and Android devices. Again, you need to choose between DIY and using a cloud service:</p><ul><li><strong>DIY. </strong>Buy a bunch of devices and write code to automate installation of new app versions on these devices.</li><li><strong>Cloud service. </strong>Use a cloud service like Browserstack or Microsoft App Center. This gives you access to a device, like an iPhone X or a Samsung Galaxy Tab, over the internet and you control it using a test automation tool, like Appium, from your own build server, like Jenkins.</li></ul><p>We chose Browserstack for three reasons:</p><ul><li>Microsoft App Center’s test-on-real-devices offering did not, at the time we looked into it, support tests written in Javascript. We could have written our tests in Java but we didn’t want to write the app in Javascript and then have to write tests in Java, as it would make the product harder to maintain for us.</li><li>Klarna already had a contract signed with Browserstack, so procuring additional capacity for our team was easy.</li><li>Purchasing and managing hardware on our own was never really an option. Our team is small and we neither have the skills nor the time to muck about with hardware. We want to focus on writing our app, not writing tools for distributing it.</li></ul><h3>Test the app using BrowserStack</h3><p>As previously mentioned, you most likely want to build a custom version of your app specifically for your integration tests running in Browserstack. You then need to download the app from App Center and upload it to BrowserStack.</p><p>Running tests as a part of your build pipeline involved these steps:</p><ol><li>build an iOS version of your app</li><li>getting Browserstack build and upload it to Browserstack,</li><li>open a tunnel between your network and BrowserStack’s network</li><li>run the test.</li></ol><p>Let’s take a look at each of these three steps.</p><h3>Build iOS App</h3><p>In order for Browserstack’s iOS devices to accept your app, you need to provide App Center with a provisioning profile and a certificate referenced in said provisioning profile.</p><p>In <a href="https://developer.apple.com/account/resources/certificates/list">https://developer.apple.com/account/resources/certificates/list</a>, you want to configure your App Certificates and Profiles like this if you want to test using Browserstack:</p><ul><li>Identifier:<br>Platform: iOS.<br>Bundle ID: Something like com.ourcompany.awesomeapp.test</li><li>Profile (i.e. Provisioning Profile):<br>Type: Development.<br>Platform: iOS.</li><li>Certificate:<br>Type: Development.</li></ul><p><em>Note that some of the above differs from how to configure things for the App Store build.</em></p><h3>Open a tunnel between your network and BrowserStack’s network</h3><p>You probably want the app to interact with your test environment, not your production environment. This probably means that the app, when running on hardware in Browserstack’s data center, needs to access services behind your own firewall. Luckily, BrowserStack provides <a href="https://www.browserstack.com/local-testing/app-automate">documentation on how to set up a tunnel between your network and BrowserStack’s network</a>. In essence, you either use their CLI or use their SDK (available for multiple programming languages). We went for the SDK approach since we then don’t have to run any Bash scripts on our Jenkins node.</p><p>Add the BrowserStack SDK as a development dependency:</p><pre>yarn add --dev browserstack-local</pre><p>Create a <em>browserstack.Local</em> object and call its <em>start</em> function before running your tests:</p><pre>import browserstack from &#39;browserstack-local&#39;<br>…<br>const browserstackLocal = new browserstack.Local()<br>…<br>const browserstackConfig = {<br>  key: &#39;your_api_key_for_browserstack&#39;,<br>  forceLocal: true<br>}<br>browserstackLocal.start(browserstackConfig,<br>  function(error) {<br>    console.log(&#39;Started BrowserStackLocal&#39;)<br>    if (error) {<br>      reject()<br>    } else {<br>      resolve()<br>    }<br>  })</pre><p><em>Note that the properties of the browserstackConfig object depends on your company’s network setup and your app’s needs. Check </em><a href="https://www.browserstack.com/local-testing/app-automate"><em>the documentation</em></a><em> to see which options you need.</em></p><p>Now the devices in BrowserStack’s data center can talk to the servers on your own network without you having to open up the firewall.</p><h3>Getting Browserstack build and upload it to Browserstack</h3><p>In order to get a downloadable iOS or Android build, which you can then upload to BrowserStack, you must first distribute the release using App Center. The thing to note here is that you don’t want to, nor need to, distribute this tailored app build to App Store or Google Play. Instead, you can configure an empty distribution group in App Center. No users will get the app since the distribution group is empty but App Center will still build a proper app for you.</p><p>So, create an empty distribution group and configure your build to automatically distribute your app to this distribution group after each build.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xBPbilXM66QtjTKi" /></figure><p>This will result in a “release” after each build in App Center. Once the release has completed (takes a minute or two) you will find the the URL to the downloadable app when you read the /v0.1/apps/${APPCENTER_ORG_NAME}/${appSlug}/releases/${releaseId} end-point.</p><p>You can now upload the app to BrowserStack like this:</p><pre>curl \<br>  -u &#39;${BROWSERSTACK_USERNAME}:${BROWSERSTACK_ACCESS_KEY}&#39; \<br>  -X POST &#39;https://api-cloud.browserstack.com/app-automate/upload&#39; \<br>  -F &#39;data={\&quot;url\&quot;: \&quot;${downloadUrl}\&quot;}&#39;</pre><p>…where downloadUrl is the URL you got from the previous App Center API call. The response from BrowserStack will include an app_url property which is what you should use to refer to this particular version of the app when you later run your tests.</p><p><em>Note: You can also “label” your app in BrowserStack and then refer to this label in your test. That way you don’t have to keep track of the </em><em>app_url value and your tests always use the app most recently uploaded to BrowserStack (which may or may not be what you want).</em></p><h3>Run the test</h3><p>Okay, you have uploaded your app to BrowserStack and you have opened a tunnel so that the app running in BrowserStack can access services on your own network. Great! Next step is to actually run your tests.</p><p>You need to initiate Appium/Webdriver so that it connects to Browserstack instead of your local Appium server.</p><p>Browserstack has a couple of good articles about writing tests for their platform:</p><ul><li><a href="https://www.browserstack.com/docs/app-automate/appium/getting-started/nodejs">Run Appium tests using Node.js</a></li><li><a href="https://www.browserstack.com/app-automate/capabilities">Capabilities for running mobile app tests on BrowserStack</a></li><li><a href="https://www.browserstack.com/docs/app-automate/appium/integrations/app-center">Test App Center builds on Appium</a></li><li><a href="https://www.browserstack.com/list-of-browsers-and-platforms/app_automate">Android and iOS Real Devices for Automated App Testing</a></li></ul><p>This is a snippet inspired by our own test setup:</p><pre>const driver = wd.promiseRemote(<br>  &#39;<a href="http://hub-cloud.browserstack.com/wd/hub&#39;">http://hub-cloud.browserstack.com/wd/hub&#39;</a><br>)<br>await driver.init({<br>  isHeadless: false,<br>  language: &#39;en&#39;,<br>  locale: &#39;en_US&#39;,<br>  app: &#39;bs://BROWSERSTACK_UPLOAD_ID&#39;,<br>  project: &#39;Awesome App on iOS&#39;,<br>  build: &#39;awesome_app&#39;,<br>  name: &#39;0001 First test&#39;,<br>  device: &#39;iPhone 8&#39;,<br>  os: &#39;ios&#39;,<br>  os_version: &#39;13&#39;,<br>  fullReset: true,<br>  &#39;browserstack.appium_version&#39;: &#39;1.15.0&#39;,<br>  &#39;browserstack.local&#39;: true,<br>  &#39;browserstack.user&#39;: &#39;YOUR_BROWSERSTACK_USERNAME_HERE&#39;,<br>  &#39;browserstack.key&#39;: &#39;YOUR_BROWSERSTACK_PASSWORD_HERE&#39;,<br>  &#39;browserstack.debug&#39;: true,<br>  &#39;browserstack.networkLogs&#39;: true,<br>  &#39;browserstack.appiumLogs&#39;: true<br>})</pre><p>You are now free to control your app in BrowserStack using commands like this:</p><pre>driver.waitForElementById(id, 5000)<br>driver.performTouchAction(action)<br>driver.performTouchAction(action)</pre><p>You’ll find more documentation about Appium and the commands on <a href="http://appium.io/docs/en/about-appium/getting-started/">http://appium.io/docs/en/about-appium/getting-started/</a>.</p><p><em>Note: Browserstack charges you per minute and this can get costly when you are developing your pipeline and you haven’t gotten the hang of it yet. When you feel that you have gotten the hang of it and you need to scale up you may want to look into upgrading your account to one with unlimited minutes (pricey, yes, but also very convenient).</em></p><p>By now you have an app that you have tested. You trust that it is working properly. Time to distribute it to the world.</p><h3>The next steps</h3><p>Continue reading here:</p><ul><li>Blog post 5/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-5-5-6ca5c2aa14b1">How to distribute the app to App Store and Google Play?</a></li></ul><p>Previous posts:<br>Blog post 1/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-1-5-3c3bf556a65b">Why automate?</a><br>Blog post 2/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-2-5-78ec48525eae">How does Jenkins orchestrate the process?</a><br>Blog post 3/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-3-5-8c390d8982f2">How is App Center configured?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3d4f05b08c8" width="1" height="1" alt=""><hr><p><a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-4-5-f3d4f05b08c8">How we publish the Klarna Point of Sale app, Part 4/5</a> was originally published in <a href="https://engineering.klarna.com/">Klarna Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we publish the Klarna Point of Sale app, Part 3/5]]></title>
            <link>https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-3-5-8c390d8982f2?source=rss-376e5465716f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c390d8982f2</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[appcenter]]></category>
            <category><![CDATA[deployment-pipelines]]></category>
            <dc:creator><![CDATA[Mikael Svensson]]></dc:creator>
            <pubDate>Fri, 06 Aug 2021 11:01:10 GMT</pubDate>
            <atom:updated>2021-08-25T14:56:57.541Z</atom:updated>
            <content:encoded><![CDATA[<p>Compiling and packaging</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_nE_Qxk0660r3Ow8MaavvQ.jpeg" /><figcaption>Packaging is always important in the retail business.</figcaption></figure><p><em>The </em><a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-2-5-78ec48525eae"><em>previous post</em></a><em> was out how we use Jenkins to orchestrate the release pipeline of our Klarna Point of Sale app. Here we’ll talk about the details of our Microsoft App Center integration.</em></p><h3>Why building and distributing using App Center?</h3><p>Microsoft App Center is a collection of services aimed at making app compilation, app deployment, app testing and app analytics easy.</p><p>Why would I use a cloud service to compile and package my code? Can’t I compile it myself? Yes and no. There is one thing that severely limits your options if you want to develop an iOS app: Apple requires that all iOS apps are compiled on Apple hardware.</p><p>This leaves you with two options:</p><ul><li><strong>DIY. </strong>Use Apple computers and spend a lot of time and effort on automating the build process. This is expensive both in terms or time and money, unless you happen to have a spare Mac and you work for free.</li><li><strong>Outsource. </strong>Use a cloud service like Microsoft App Center and let them own, maintain and automate the hardware. We went for this solution mostly because of the simplicity, but it is also because App Center is very competitively priced (starting at $40 per month).</li></ul><blockquote>Basically, using App Center saves us time and money.</blockquote><p>Besides cost savings, a key feature of App Center is that it supports distributing your app to both Apple’s app store and Google’s app store. Apple and Google have chosen widely different mechanisms for uploading apps to their stores and it is therefore <em>very convenient that App Center abstracts away this complexity for you</em>.</p><h3>Compile the app using App Center</h3><p>Since App Center compiles the app for you, it needs access to your source code. There are <a href="https://docs.microsoft.com/en-us/appcenter/build/connect">a few options</a> available, including Github and Azure Devops. We went for a private Github repo. Not perfect but good enough.</p><p>Once you have the source code on Github you, preferably, configure App Center to automatically build your app whenever you push changes to your Github repository.</p><p>There are a couple of things to be aware of here:</p><ul><li>You will be uploading your source code, which likely is considered company secrets, to Github and Microsoft. Make sure that your company is fine with this.</li><li>App Center’s build servers can’t access your company’s internal Git repos or package repositories. This means that you will have to jump through some hoops if your app uses Javascript libraries which are not public. More on this later in the <em>Private libraries</em> section.</li><li>You don’t control what software is installed on App Center’s build servers. Microsoft provides a very nice <a href="https://docs.microsoft.com/en-us/appcenter/build/macos-10.15-software">list of which versions of which tools are available on the build servers</a>, but the list can change and then you may have to make tweaks to your code or build scripts to accommodate these changes. Just so you know.</li></ul><p>In the following sections you will find this information:</p><ul><li><strong>Private libraries. </strong>So that your app can be based on non-public libraries, for example libraries developed by other teams in your company and published to internal repositories.</li><li><strong>Different environments, different options. </strong>So that you can build different versions of your app for slightly different purposes.</li><li><strong>iOS Build Number. </strong>So that App Store will not complain.</li><li><strong>Quirk to include correct Javascript bundle for Android. </strong>So that the app will work on Android.</li><li><strong>Signing for iOS. </strong>So that you can run the app on real iOS devices.</li><li><strong>Signing for Android. </strong>So that you can publish the app to Google Play.</li></ul><h3>Private libraries</h3><p>App Center can only build your app if all the necessary source code is either inside your Git repo or downloadable from public repositories. This means that you cannot reference packages in your package.json which are in package repositories, like Artifactory, behind your company’s firewall.</p><p>Luckily, you can get around this by using Yarn’s “offline mirror” feature and then commit copies of all your dependencies to your Git repo. It’s not pretty but it works.</p><p>This is what we ended up with on our Jenkins:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95a95610ff03711bd59c940383ebeca3/href">https://medium.com/media/95a95610ff03711bd59c940383ebeca3/href</a></iframe><p><em>Note that </em><em>APPIUM_SKIP_CHROMEDRIVER_INSTALL=true is not required to get private libraries (offline cache) to work. It’s there to aid testing later on.</em></p><p>Now that your GitHub repository contains all the necessary files, it’s time to take a look at how to build different variants of the app for different use cases.</p><h3>Different environments, different options</h3><p>You probably want to build different variants of your app for different use cases, like one to be used during integration tests and one to be distributed to the app stores. Both these variants would use the same source code but different configuration values.</p><p>Examples of would might be different between the integration test variants and the app store variants:</p><ul><li>different API end-points (test data vs live data),</li><li>different log-in mechanisms (predefined test users vs OpenID users),</li><li>different app icons and color themes (beta version icon vs regular icon).</li></ul><p>There are multiple ways of providing environment-specific configuration values in React Native and for our app we chose the library <a href="https://github.com/luggit/react-native-config">react-native-config</a>. You will find <a href="https://github.com/luggit/react-native-config#setup">step-by-step installation instructions</a> for both iOS and Android on their Github page but we’ll describe the general concept below.</p><p>First you create a .env file in the root of our project. Something like this:</p><pre><strong>API_HOSTNAME = api.your-company.com<br></strong>API_KEY = phq9KzSGQcRbaUsFvyo9m6J6meLCiL5tfLSDgMY232Y9BBfBSw<br>USE_OPENID_TO_SIGN_IN = true</pre><p>Then you access the values like this in your code:</p><pre><strong>import Config from &#39;react-native-config&#39;</strong></pre><pre>const fetchData = async () =&gt; {<br>  const resp = await fetch(<br>    `https://${<strong>Config.API_HOSTNAME</strong>}/resource/1`<br>  )<br>  return resp.json()<br>}</pre><p>You have two options for telling react-native-config where to find the correct configuration properties:</p><ol><li><strong>Pick .env file. </strong>Create one configuration file for each environment and specify which file to use with an environment variable. Read more about this option on <a href="https://github.com/luggit/react-native-config">luggit/react-native-config</a>’s Github page (in a nutshell, you set the environment variable ENVFILE to point to the correct file).</li><li><strong>Generate .env file. </strong>Create a Bash script which generates the .env file on the App Center build server just before the build starts. This is likely the best option if your configuration contains secrets, such as API keys.</li></ol><p>We’ll describe option 2 here:</p><ul><li>Define all your values as individual <a href="https://docs.microsoft.com/en-us/appcenter/build/custom/variables/">environment variables in App Center</a>.</li><li>Add a script called appcenter-pre-build.sh to the root of our project. In this Bash script, echo the environment variables, i.e. configuration properties, one by one to the .env file.</li></ul><p>Example appcenter-pre-build.sh script:</p><pre>echo &quot;API_HOSTNAME=${API_HOSTNAME}&quot; &gt;&gt; .env<br>echo &quot;API_KEY=${API_KEY}&quot; &gt;&gt; .env<br>echo &quot;USE_OPENID_TO_SIGN_IN=${USE_OPENID_TO_SIGN_IN}&quot; &gt;&gt; .env</pre><p><em>Note: New scripts are not automatically “picked up” by App Center — read more about this on </em><a href="https://docs.microsoft.com/en-us/appcenter/build/custom/scripts/"><em>https://docs.microsoft.com/en-us/appcenter/build/custom/scripts/</em></a><em>.</em></p><p>Okay, so you can now customize your build for different environments! Awesome, but we’re not done yet. The app cannot be uploaded to Apple’s App Store unless each new build has a unique “bundle version”. Let’s fix that…</p><h3>iOS Build Number</h3><p>Each iOS build needs to have a unique “bundle version”. For this, you can use the build id that App Center generates for each build. The build id is available in the APPCENTER_BUILD_ID environment variable.</p><p>Set the iOS bundle version using the plutil tool as part of your appcenter-pre-build.sh script:</p><pre>plutil \<br>  -replace CFBundleVersion \<br>  -string &quot;${APPCENTER_BUILD_ID}&quot; \<br>    ${APPCENTER_SOURCE_DIRECTORY}/ios/your_app_name/Info.plist</pre><p><em>Note: </em><em>pltool is available on App Center build servers by default.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/0*nDG9iETDo2p-H2GP" /><figcaption>App Center can generate the build number in different ways.</figcaption></figure><h3>Android Build Number</h3><p>Each Android build also needs to have a unique “bundle version”. One simple way to accomplish this is to set it to the current timestamp (and not use the predefined environment variable from App Center).</p><p>Add this to your app/build.gradle:</p><pre>android {<br>  …<br>  defaultConfig {<br>    versionCode (new Date().time / 1000).intValue()<br>    …<br>  }<br>  …<br>}</pre><h3>Quirk to include correct Javascript bundle for Android</h3><p>You need to add a “patch” to your app/build.gradle in order to circumvent a <a href="https://github.com/facebook/react-native/issues/29398">bug/quirk when building React Native in App Center</a>. The problem is that App Center uses the wrong Javascript file when bundling your app and the app simply crashes when you try to start it. The solution (i.e. hack) is to copy the Javascript bundle from where it actually ends up to where App Center expected it to end up.</p><p>Add this to your app/build.gradle:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c14f1fb582866845ad883d3b5d09381/href">https://medium.com/media/7c14f1fb582866845ad883d3b5d09381/href</a></iframe><p>The hack listens for when the “bundle task” is completed and then copies the generated Javascript file from the output folder to the <em>src/main/assets</em> folder, which is where App Center expects it to be. Not ideal, but it works.</p><h3>Signing for iOS</h3><p>An iOS app must be digitally signed in order to be installed on a real device, be it your own or one of Browserstack’s. Either way, you need to configure your App Center build to sign the app. Microsoft has a good article about <a href="https://docs.microsoft.com/en-us/appcenter/build/ios/code-signing">how to enable code signing for iOS in App Center</a>.</p><p>In short, you need to create three things to compile and sign your app:</p><ul><li>Create <em>Identifier</em> at <a href="https://developer.apple.com/account/resources/identifiers/list">https://developer.apple.com/account/resources/identifiers/list</a>:<br>Platform: iOS.<br>Bundle ID: Something like com.ourcompany.awesomeapp</li><li>Create a <em>Certificate</em> at <a href="https://developer.apple.com/account/resources/certificates/list">https://developer.apple.com/account/resources/certificates/list</a>. For this step you also need to <a href="https://stackoverflow.com/questions/12126496/how-to-obtain-certificate-signing-request">create a CSR file</a>.<br>Certificate Type: iOS Distribution.</li><li>Create a <em>(Provisioning) Profile</em> at <a href="https://developer.apple.com/account/resources/profiles/list">https://developer.apple.com/account/resources/profiles/list</a>. The provisioning profile connects your certificate to your app id.<br>Type: App Store.<br>Platform: iOS.</li></ul><p>You then need to export your certificate as a .p12 file. Instructions on how to do it is found at the end of the previously mentioned article on <a href="https://docs.microsoft.com/en-us/appcenter/build/ios/code-signing">how to enable code signing for iOS in App Center</a>.</p><p>Finally you upload your provisioning profile file and your certificate file to App Center when configuring your build:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XcdhFFd-7j0NTwnD" /></figure><h4>Tip: Different App Ids</h4><p>If you are planning on offering a beta version of your app, or just want to be able to install both your debug variant and your production variant on the same device during development, then you want to register one “app id” for each such app variant.</p><h3>Signing for Android</h3><p>Signing a build for Android, so that it can be accepted by Google Play, involves specifying your “keystore passwords” as environment variables in App Center (remember to click the lock icon so that the passwords are encrypted by App Center).</p><p><em>Unfamiliar with signing Android apps? Check out </em><a href="https://support.google.com/googleplay/android-developer/answer/7384423"><em>Use app signing by Google Play</em></a><em>, </em><a href="https://developer.android.com/studio/publish/app-signing"><em>Sign your app</em></a><em> and </em><a href="https://reactnative.dev/docs/signed-apk-android"><em>Publishing [React Native app] to Google Play Store</em></a><em> for more information.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u-_tGzDzb0w0AXdK" /><figcaption>Define the keystore password as encrypted environment variables in App Center.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o6-NSGiMW213IM4L" /><figcaption>Tick this box to prevent App Center from using its own mechanism for signing the app.</figcaption></figure><p>Then have the appcenter-pre-build.sh script output the two passwords as properties in android/gradle.properties:</p><pre>echo &quot;APP_UPLOAD_STORE_PASSWORD: ${APP_UPLOAD_STORE_PASSWORD}&quot; &gt;&gt; android/gradle.properties<br>echo &quot;APP_UPLOAD_KEY_PASSWORD: ${APP_UPLOAD_KEY_PASSWORD}&quot; &gt;&gt; android/gradle.properties</pre><p>And finally update signingConfigs in your app/build.gradle:</p><pre>signingConfigs {<br>  …<br>  release {<br>    storeFile file(&#39;path_to_your_keystore_file&#39;)<br>    storePassword APP_UPLOAD_STORE_PASSWORD<br>    keyAlias &#39;name_of_your_key_in_your_keystore&#39;<br>    keyPassword APP_UPLOAD_KEY_PASSWORD<br>  }<br>}</pre><p>After all that boring stuff with environment variables and signing, let’s move on the fun bit of starting build and controlling App Center using its API.</p><h3>API for controlling App Center</h3><p>App Center’s website provides a very good user experience and it’s easy to configure a basic build pipeline yourself without any programming. You basically specify which Git branch to build, which Node version to use, if you want to do a “smoke test” using one of App Center’s real devices, and if you want to distribute your app to an app store. This might be all you need and then you can stop reading now, but if you want more control you should look into controlling App Center using its API.</p><p>App Center’s API which covers pretty much everything you can do with App Center and it is fairly well documented on <a href="https://openapi.appcenter.ms/">https://openapi.appcenter.ms/</a>.</p><p>You’ll need API credentials to use the API. Get credentials by signing in to the App Center website and generate API credentials on <a href="https://appcenter.ms/settings/apitokens">https://appcenter.ms/settings/apitokens</a>.</p><p>It’s a regular REST API and most of the time you only need to make one API call to make something happen. Here’s an example of how to start a build:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bc9026cca789b24cc705ea9af2b838f/href">https://medium.com/media/2bc9026cca789b24cc705ea9af2b838f/href</a></iframe><p>The build command above will return a build id (amongst other things) and you can then poll another endpoint, say once per minute, to check if the build has completed (or failed).</p><h3>The next steps</h3><p>Continue reading here:</p><ul><li>Blog post 4/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-4-5-f3d4f05b08c8">How to run tests in Browserstack?</a></li><li>Blog post 5/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-5-5-6ca5c2aa14b1">How to distribute the app to App Store and Google Play?</a></li></ul><p>Previous posts:<br>Blog post 1/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-1-5-3c3bf556a65b">Why automate?</a><br>Blog post 2/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-2-5-78ec48525eae">How does Jenkins orchestrate the process?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c390d8982f2" width="1" height="1" alt=""><hr><p><a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-3-5-8c390d8982f2">How we publish the Klarna Point of Sale app, Part 3/5</a> was originally published in <a href="https://engineering.klarna.com/">Klarna Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we publish the Klarna Point of Sale app, Part 2/5]]></title>
            <link>https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-2-5-78ec48525eae?source=rss-376e5465716f------2</link>
            <guid isPermaLink="false">https://medium.com/p/78ec48525eae</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Mikael Svensson]]></dc:creator>
            <pubDate>Thu, 03 Jun 2021 15:16:17 GMT</pubDate>
            <atom:updated>2021-08-25T14:56:59.373Z</atom:updated>
            <content:encoded><![CDATA[<p>The Pipeline</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_nE_Qxk0660r3Ow8MaavvQ.jpeg" /><figcaption>The person in blue benefits from our automated pipeline.</figcaption></figure><h3>The Pipeline has three main tasks</h3><p>In essence, we designed our pipeline in <strong>Jenkins</strong> to do this:</p><ol><li><em>Start</em> the Jenkins pipeline by listening for Git commits.</li><li><em>Compile</em> the app using App Center.</li><li><em>Test</em> it on real devices using Browserstack.</li><li><em>Distribute</em> it to app stores using App Center.</li></ol><p>A rough sketch of how the pieces above fit together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*-wBSfpusQpVyGn6AzvKCpg.png" /><figcaption>Jenkins is the orchestrator and initiates all the actions to Browserstack and App Center.</figcaption></figure><h3>Why Jenkins to orchestrate the build process?</h3><p>Jenkins is a flexible and highly customizable build server. You can use it to compile code. Or to schedule scripts. Or to orchestrate a build pipeline, like in our case.</p><p>Do you have to use Jenkins? No, you only need something that can make http requests, like a Bash script with curl commands, but Jenkins allows you to add some bells and whistles, like parallelism and encrypted API credentials. Jenkins is the de facto standard for these kinds of tasks at Klarna, so for us the choice was easy.</p><p>Now let’s take a look at two topics related to “releasing with confidence”…</p><h3>Breadcrumbs in Jenkins for confidence</h3><p>Ensuring that we are <em>building precisely what we meant to build</em> is essential for any app developer. With a complex CI/CD pipeline, like ours, it is easy to make subtle mistakes which can be hard to notice and debug.</p><p>To prevent such mistakes, we have a pipeline where each step returns some kind of “tracking identifier”, like a build id or a commit hash, and feeds that data to the next step so that each step clearly depends on the previous.</p><p>Like this:</p><ul><li>Developer commits and pushes new change to Git and gets Git hash YOUR_GIT_HASH back.</li><li>Jenkins pipeline starts with parameter YOUR_GIT_HASH.</li><li>Job clones internal Git repo and gets Git hash YOUR_GIT_HASH.</li><li>Push commit YOUR_GIT_HASH to Github and get the resulting Git hash from Github, GITHUB_GIT_HASH. (Pushing to Github is necessary because App Center cannot get source code from privately hosted Git servers.)</li><li>Trigger build in App Center and make sure it picks up the correct revision from Github, i.e. commit GITHUB_GIT_HASH. App Center returns BUILD_ID.</li><li>Trigger a release (App Center terminology) from build BUILD_ID. App Center returns RELEASE_ID.</li><li>Find release RELEASE_ID in App Center and get the URL from where the app generated from this release can be downloaded. Let’s call it APP_URL.</li><li>Download the app from APP_URL and upload it to Browserstack. We get an “upload id” back from Browserstack. Unsurprisingly, we’ll save this in a variable called UPLOAD_ID.</li><li>Start Appium tests on Browerstack and use the Browserstack UPLOAD_ID to specify which app to start on the actual test devices.</li><li>Distribute app to app stores based on the RELEASE_ID we got from App Center earlier.</li></ul><p>That’s it. As long as we keep the Jenkins log around we will now have good traceability of what went in to every single release.</p><h3>Go/No-Go step for confidence</h3><p>A go/no-go step is allows you to stop the build pipeline and wait for a human, like a product manager, to make an active decision about whether or not to proceed with the build.</p><p>Why is this important? Well, your build pipeline is probably set up to be triggered every time you commit to master but do not want to release every build to production. You want a product manager do sign off on everything that actually gets released to the end-users.</p><p>More on the go/no-go step in the last blog post in this series.</p><h3>The next steps</h3><p>Continue reading here:</p><ul><li>Blog post 3/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-3-5-8c390d8982f2">How is App Center configured?</a></li><li>Blog post 4/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-4-5-f3d4f05b08c8">How to run tests in Browserstack?</a></li><li>Blog post 5/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-5-5-6ca5c2aa14b1">How to distribute the app to App Store and Google Play?</a></li></ul><p>Previous posts:<br>Blog post 1/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-1-5-3c3bf556a65b">Why automate?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78ec48525eae" width="1" height="1" alt=""><hr><p><a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-2-5-78ec48525eae">How we publish the Klarna Point of Sale app, Part 2/5</a> was originally published in <a href="https://engineering.klarna.com/">Klarna Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we publish the Klarna Point of Sale app, Part 1/5]]></title>
            <link>https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-1-5-3c3bf556a65b?source=rss-376e5465716f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c3bf556a65b</guid>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[appcenter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[deployment-automation]]></category>
            <category><![CDATA[browserstack]]></category>
            <dc:creator><![CDATA[Mikael Svensson]]></dc:creator>
            <pubDate>Thu, 03 Jun 2021 14:02:19 GMT</pubDate>
            <atom:updated>2021-08-25T14:57:01.457Z</atom:updated>
            <content:encoded><![CDATA[<p>Using Jenkins, Microsoft App Center and Browserstack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_nE_Qxk0660r3Ow8MaavvQ.jpeg" /><figcaption>The store clerk to the left is using Klarna Point of Sale.</figcaption></figure><p>This article is for you if you have an existing React Native app but you feel your deployment process is error-prone, labor-intensive, or boring.</p><p>After reading this five-part blog post you will know how to automate the deployment process for your React Native to Google Play and Apple Store using the cloud services Microsoft App Center and Browserstack.</p><p>In this blog post series we’ll be using three services/products:</p><ul><li><strong>Microsoft App Center</strong>, which is a really nice cloud service for compiling React Native apps and distributing them to both Google Play and Apple Store.</li><li><strong>Browserstack</strong>, which is a cloud service for, amongst other things, testing native apps on real devices.</li><li><strong>Jenkins</strong>, which is the deployment server of choice at Klarna.</li></ul><p><em>If you instead only want to play around with React Native you may be better off reading </em><a href="https://reactnative.dev/docs/tutorial"><em>React Native: Learn the Basics</em></a><em> or </em><a href="https://reactjs.org/tutorial/tutorial.html"><em>Tutorial: Intro to React</em></a><em> or </em><a href="https://dev.to/alexandrumic/an-introduction-to-react-native-gje"><em>An Introduction to React Native</em></a><em>.</em></p><h3>Why automate in the first place?</h3><p>At Klarna we want to release to production often in order to quickly adapt to the needs of our users. The idea is to make small updates often. Start small, learn fast. An important mechanism for achieving this is to automate the build and deployment process of our apps, i.e. to implement CI/CD (Continuous Integration and Continuous Delivery).</p><p>You get many benefits from automation:</p><ul><li><strong>Traceability. </strong>An automated process can produce audit trails which can be useful both when something goes wrong and to prevent things from ever going wrong. Since Klarna is a bank, traceability is especially important to us.</li><li><strong>Predictability. </strong>Humans make mistakes. We all do. By automating as much as possible, and verifying that the automation works as expected, you greatly reduce the risk of someone making a mistake when performing a task, or someone forgetting to perform a task, as part of a release process.</li><li><strong>Maintainability. </strong>By adhering to the principle of “pipeline as code”, i.e. by defining the build-and-deploy workflow as a version-controlled script, you can use your usual routines for code review and ensure that your automated process stays maintainable. The alternative would be to have some document with manual instructions and copy-and-paste commands which may or may not be up to date, may or may not work for all users, and so on.</li></ul><p>Both App Center and Browserstack have REST APIs which enables you to write fully automated build-and-deploy pipelines tailored for your needs.</p><p>Jenkins controls the deployment process like this:</p><ol><li><strong>Jenkins</strong> tells <strong>App Center</strong> to compile and package our app.</li><li><strong>Jenkins</strong> tells <strong>Browserstack</strong> to run our integration tests.</li><li><strong>Jenkins</strong> tells <strong>App Center</strong> to distribute our app to Apple Store and Google Play.</li></ol><h3>The next steps</h3><p>That was a short introduction.</p><p>The fact that this is not one but five blog posts might make the whole automation process seem daunting, and there is no denying that all the small things add up, but I’d argue that it’s well worth the effort. Automation ensures that you have a reliable and predictable way of deploying your app.</p><p>Now it is time to dig into the details:</p><ul><li>Blog post 2/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-2-5-78ec48525eae">How does Jenkins orchestrate the process?</a></li><li>Blog post 3/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-3-5-8c390d8982f2">How is App Center configured?</a></li><li>Blog post 4/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-4-5-f3d4f05b08c8">How to run tests in Browserstack?</a></li><li>Blog post 5/5: <a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-5-5-6ca5c2aa14b1">How to distribute the app to App Store and Google Play?</a></li></ul><blockquote>About the author: I’m in the the team developing one of Klarna’s lesser known apps, called <em>Klarna | Point of Sale</em>. This app is for retailers and merchants, not consumers. The consumer app, simply named <em>Klarna | Smoooth shopping</em>, was released a couple of years ago and has a different release process and will not be covered here. Anyway… In this article you will read about how to build, test and distribute your React Native app using Microsoft App Center and BrowserStack.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c3bf556a65b" width="1" height="1" alt=""><hr><p><a href="https://engineering.klarna.com/how-we-publish-the-klarna-point-of-sale-app-part-1-5-3c3bf556a65b">How we publish the Klarna Point of Sale app, Part 1/5</a> was originally published in <a href="https://engineering.klarna.com/">Klarna Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I Love Our Partnership With helloworld.se]]></title>
            <link>https://engineering.klarna.com/why-i-love-our-partnership-with-helloworld-se-4d007d10e729?source=rss-376e5465716f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d007d10e729</guid>
            <category><![CDATA[csr]]></category>
            <category><![CDATA[people]]></category>
            <category><![CDATA[kids-programming]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[kids-and-tech]]></category>
            <dc:creator><![CDATA[Mikael Svensson]]></dc:creator>
            <pubDate>Wed, 30 Aug 2017 06:17:43 GMT</pubDate>
            <atom:updated>2017-09-01T06:14:48.310Z</atom:updated>
            <content:encoded><![CDATA[<p>Is corporate social responsibility (CSR) just a way of getting free publicity by giving money to worthy causes or is it actually propelling society in the right direction? Hopefully it is all about the latter, and I love that Klarna is taking part in helping young people embrace and discover new technologies!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hIYwrEMxbmXyXT3Xs_La6g.jpeg" /><figcaption>Image from Hello World’s website</figcaption></figure><h3>What is Hello World?</h3><p>Hello World is a Swedish non-profit aiming to encourage and inspire “computer-aided creativity” amongst kids and teenagers. This boils down to meet-ups and summer camps where participants work with for example programming, 3D printing and electronics. An interesting aspect of their mission is the goal to have a 50/50 split of girls and boys at their events, a very positive thing in a time when we want to encourage girls and women to start working with science and technology.</p><p>Their <a href="https://helloworld.se/partners/">impressive list of partners</a> shows that this is something that a lot of people value. Side note: Klarna has hosted a meet-up for kids, has arranged a workshop for the Hello World instructors and has provided <a href="https://github.com/mikaelsvensson/helloworld-spychallenge">programming challenges</a> for the Hello World <a href="https://helloworld.se/lager/">summer camp</a>.</p><h3>Do We Need Initiatives Like Hello World?</h3><p>Hello World and similar initiatives are about helping young people discover and nurture their talents together with other likeminded young people. Software development is something that <em>can</em> be done by yourself but it is just way more productive and fun to do it with others. Meeting others like you is very important, especially when you happen to be interested in something that does not <em>require</em> you to be a part of a group, as opposed to for example playing football or singing in a choir.</p><p>So, do we need these meet-ups and summer camps for tech-curious children and teenagers?</p><p>Yes, I truly believe so, just by looking at myself… I love programming. I love making life easier, for myself or others, by developing tools which simplify and automate the boring parts of our lives. Had I been more creative and artistic I would also have made the world more user-friendly and beautiful at the same time, but for now I gladly let other people take care of the art part of technology. We all have our strengths and weaknesses. No one is good at everything, meaning that societies and companies need to encourage their people, young and old, to go out and find what they are good at.</p><p>I suppose this sometimes translates to “we need to embrace diversity in the workplace”, and while that is certainly true that we must all work hard against discrimination and biases, I think it is equally important to show kids and teenagers that the tech industry is for everyone. We must not let young people from under-represented groups, like women, feel like outsiders. By limiting the talent pool, unconsciously or not, we lower the pace of innovation and progress. Hello World’s ambition of having just as many girls as boys at their meet-ups and camps is a very good idea for fostering a culture where gender in tech is no longer an issue.</p><p>An interesting aspect of reaching out to girls in particular is that <a href="http://www.soi2016.se/flickor-och-pojkar-kvinnor-och-man/kunnighet/">both girls and boys feel equally “tech savvy” when they are 12–15</a> but then something happens and young women between 16 and 25 feel a bit less confident in their “tech skills” than young men (note that this is about confidence level, not actual skill level). This becomes all too apparent when looking at the <a href="https://www.svt.se/nyheter/inrikes/vill-ha-fler-kvinnor-i-teknikjobb">low number of women at university engineering programmes</a> in Sweden and listening to Swedish IT consultant <a href="https://www.youtube.com/watch?v=A0D8TlTP9uc">Ulrika Malmgren talking to a group of potential engineering students</a>. Ensuring that young women stay interested in technology is therefore very important for the tech industry. Luckily there are many women in Swedish tech companies who girls might feel inspired by, and some of those women are included in DI’s list of <a href="http://digital.di.se/artikel/har-ar-kvinnorna-som-formar-tech-sveriges-framtid">24 women who shape the future for Swedish tech</a>.</p><p>Getting back to kids in general, both girls and boys, we find additional proof of the value of private initiatives to encourage young people to pursue a career, or hobby, in technology (and science and academia) in an <a href="https://old.liu.se/liu-nytt/arkiv/mn/1.715288?l=sv">interview with researcher Anders Jidesjö</a>:</p><blockquote>“It is often said that children and teenagers are not interested in natural sciences and technology. That is not true. They have a lot of interests in those fields but sometime around the 8th grade it crashes. […] It seems school ruins their interest.”</blockquote><p>The observation that kids, or at least girls, lose interest in computer technology around the 8th grade is also mentioned in an article from 2015 which talks about how <a href="http://pedagog.stockholm.se/teknik/dataslojd-for-flickor-ar-en-fraga-om-demokrati/">getting girls interested in programming is a matter of democracy</a>. A lot of people are, luckily, working to change this. One example are teachers Jannike Kohinoor and Helena Dalivin who started Girls Code <a href="http://www.teacherhack.com/2015/09/17/programmering-pa-malarhojdens-skola-2/">back in 2015</a>, and who recently <a href="http://pedagogblogg.stockholm.se/urflippat/2016/10/29/girls-code-pa-microsoft/">visited Microsoft</a> with a group of girls.</p><p>Another excellent example of things moving in the right direction is 12-year-old developer Greta Nygren who, amongst other things, has published a <a href="https://www.youtube.com/watch?v=pDa0w2zgtPE">38-minute video on automating Minecraft using Python</a>. She was recently <a href="http://www.stockholmdirekt.se/nyheter/greta-12-lar-ut-programmering-i-egen-kanal/repqfp!DCayLCz@fIhgqRAbEX4Pyg/">interviewed by StockholmDirekt</a>, in case you want to know more.</p><p>So, we should all try to encourage young people to continue exploring the world of science and technology!</p><h3>How Can You And I Help?</h3><p>Personally, I imagine that two things are needed:</p><ul><li>Get children and teenagers interested in all the wonderful things one can do with a computer, like develop games and produce digital content.</li><li>Make sure that workplaces are inclusive, so that under-represented groups feel at ease and feel valued. There is no point in getting under-represented groups, like young women, to become developers if they quit the business because of <a href="https://www.susanjfowler.com/blog/2017/2/19/reflecting-on-one-very-strange-year-at-uber">poor working conditions</a>.</li></ul><p><em>(Side note: I do not think I, a white 30-something Swedish man with a degree in computer science, should be too confident when it comes to providing ideas for helping people who do not fit the stereotypes of software engineers. I will gladly take advice from people with more insight!)</em></p><p>Anyway… If you want to learn more about initiatives and organizations working to promote computer technology you might want to take a close look at these:</p><ul><li><a href="http://www.pyladies.com/">PyLadies</a> is a “group of women developers worldwide who love the Python programming language”. <a href="https://medium.com/u/36d52eb6804f">Mariana Bocoi</a>, one of my colleagues at Klarna, arranged a meet-up for female developers in Stockholm where they <a href="https://www.meetup.com/PyLadiesStockholm/events/240781373/">developed a chat-bot using Python and Heroku</a>.</li><li>Swedish <a href="https://helloworld.se/">Hello World</a> is sort of what this article is all about, organizations trying to get kids and teens interested in technology.</li><li><a href="https://scratch.mit.edu/">Scratch</a> is a very popular game development tool for children which has seen a <a href="https://scratch.mit.edu/statistics/">tremendous growth over the last three years</a>.</li><li>Swedish <a href="https://www.kodcentrum.se/">Kodcentrum</a> is non-profit organization providing <em>free</em> workshops and meet-ups for kids interested in programming and creating digital content. They also host <a href="https://www.kodboken.se/">Kodboken</a>, a web site for adults who want to help children with programming. Side note: You can submit an application to <a href="https://www.kodcentrum.se/bli-volontar/bli-volontar">become a volonteer</a> on their web site.</li><li>Swedish <a href="http://programming4kids.se/">Programming4Kids</a> provide camps and courses in robotics and Scratch.</li><li>Swedish <a href="http://coderdojostockholm.se/">CoderDojo Stockholm</a> is a rather informal network providing free “coding dojos” for kids and teenagers. Companies like Skype, Bettson and Bisnode hosted their <a href="http://coderdojostockholm.se/varterminen-2017-datum-och-platser/">spring 2017 dojos</a>.</li><li>Swedish IIS has links to <a href="https://www.iis.se/vad-vi-gor/barnhack/barnhacksinitiativ-i-sverige/">some twenty Swedish cities where you can attend meet-ups and coding dojos for kids</a>.</li><li>Swedish <a href="http://www.tjejerkodar.se/">Tjejer Kodar</a> provide training and camps for women in tech.</li><li>Swedish <a href="http://www.pinkprogramming.se/en">PINK Programming</a> is “a non-profit organization [working] to enable more women to discover the joy of programming [and] to increase the proportion of women working in the tech industry.”</li></ul><p><strong>Which of all these will you be signing up for?</strong></p><h3>Appendix: More Reading</h3><p>CSR ambitions of various tech companies (most are in Swedish):</p><ul><li>Swedish consultancy company <a href="https://chas.se/csr/">Chas</a> has a bunch of local commitments, including helping shelters for the homeless, donating money to cancer research, and promoting technology at a school in a socioeconomically low-ranking neighbourhood in Stockholm.</li><li>Swedish consultancy company <a href="http://sigma.se/csr/">Sigma</a> focuses on local initiatives in Malmö and their <a href="http://www.starforlife.se/">Star for Life</a> projects in Africa.</li><li>Swedish <a href="https://www.tng.se/csr">TNG</a> works to integrate immigrants in the society, promote programming for women, promote programming among children, and donate money to charity.</li><li>CSR at <a href="https://news.microsoft.com/sv-se/sokord/csr/#sm.0000116yrk42x3fpxv16o3sqzh55n#8bXHIAHDJyYT4COM.97">Microsoft</a> is, among other things, about young inventors, immigrant integration, free software for charity organizations and promoting programming among children.</li><li>Forbes recently published an article about <a href="https://www.forbes.com/sites/susanmcpherson/2017/06/20/how-spotify-uses-music-to-drive-social-change/">How Spotify Uses Music To Drive Social Change</a>. Spotify has also started <a href="http://musically.com/2017/06/12/spotify-max-martin-equalizer-project/">The Equalizer Project</a>, aimed at helping female songwriters and producers.</li><li>PayPal has started <a href="https://www.paypal.com/givingfund/home">Giving Fund</a>, a charity providing payment services for free to charity organizations.</li><li>Accenture’s initiative to <a href="https://www.accenture.com/us-en/company-skills-succeed">help 3 million people</a> with things like getting an education or starting companies was featured in the Ny Teknik article <a href="https://www.nyteknik.se/karriar/nu-vill-alla-foretag-ta-sitt-ansvar-for-csr-6424210">Nu vill alla företag ta sitt ansvar för CSR</a> (2010) .</li></ul><p>Articles about CSR in general (most are in Swedish):</p><ul><li><a href="http://traomobelforum.se/susanne-sweet-csr-ar-en-mastefraga-for-stora-foretag/">Susanne Sweet: CSR är en måstefråga för stora företag</a></li><li><a href="https://cio.idg.se/2.1782/1.580496/it-foretag-inte-tillrackligt-engagerade-i-csr-fragor">It-företag inte tillräckligt engagerade i CSR-frågor</a></li><li><a href="http://www.teacherhack.com/programmering/">Länkar till intiativ kring barn och datorer</a></li><li><a href="http://www.svenskhandel.se/globalassets/dokument/aktuellt-och-opinion/rapporter-och-foldrar/hallbar-handel/csr-broschyr.pdf">Så kan ditt företag arbete med etik och socialt ansvarstagande</a></li><li><a href="https://www.svd.se/en-csr-nagel-i-foretagens-ogon">En CSR-nagel i företagens ögon</a></li><li><a href="http://blog.handup.org/posts/corporate-social-responsibility">How to Make Social Impact a Part of Your Company From Day One</a></li><li><a href="http://www.csrsweden.se/wp-content/uploads/2014/04/SU_CSRiFramtiden.pdf">CSR — Hur kommer det utvecklas i framtiden?</a> (research paper)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d007d10e729" width="1" height="1" alt=""><hr><p><a href="https://engineering.klarna.com/why-i-love-our-partnership-with-helloworld-se-4d007d10e729">Why I Love Our Partnership With helloworld.se</a> was originally published in <a href="https://engineering.klarna.com/">Klarna Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I Failed Teaching Programming to Kids]]></title>
            <link>https://engineering.klarna.com/why-did-i-fail-teaching-programming-to-kids-46a854c3eaca?source=rss-376e5465716f------2</link>
            <guid isPermaLink="false">https://medium.com/p/46a854c3eaca</guid>
            <category><![CDATA[children]]></category>
            <category><![CDATA[teaching]]></category>
            <category><![CDATA[kids-and-tech]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Mikael Svensson]]></dc:creator>
            <pubDate>Thu, 02 Mar 2017 16:02:02 GMT</pubDate>
            <atom:updated>2017-03-02T16:12:52.004Z</atom:updated>
            <content:encoded><![CDATA[<p>How do you teach chat bot development to teenagers in two hours? This was the challenge for me and my colleague when we set out to plan a two-hour session on mobile chat bot development for kids and teenagers.</p><p>First things first: This is a blog post about teaching, not programming. More specifically it is a blog post about teaching written by someone who is not a teacher. I am only a programmer, but hopefully my experiences could be useful to other geeky tech people who find themselves wanting to spread the word of our wonderful profession :-)</p><p>This is what this post is about:</p><ol><li>some background (the section <em>Let’s Get Started</em>),</li><li>some planning (the section <em>How To Make It Engaging?</em>)</li><li>some risk management (the section <em>What Could Possibly Go Wrong?</em>),</li><li>some revelations (the section <em>What Did Go Wrong?</em>)</li><li>some conclusions (the section <em>Will I Do Things Differently Next Time?</em>).</li></ol><h3>TL;DR</h3><ul><li>You can’t prepare for everything.</li><li>Keep your calm and adapt when things go wrong.</li></ul><h3>Let’s Get Started</h3><h4>Why am I writing this?</h4><p><a href="https://www.klarna.com/se/">Klarna</a> hosted a <a href="https://helloworld.se/">Hello World</a> meet-up earlier this year. Hello World is a Swedish non-profit organisation aiming to get kids and teens interested in software development. Kids and teenagers can sign up for various sessions during these meet-ups. Some sessions, like introductions to Scratch and Python, are recurring and some are one-off things. Me and my colleague set out to prepare a one-off session.</p><p>I have some experience working with kids and some experience doing technical presentations for people without much computer experience but would that be enough?</p><p>Let me put it this way; I write this for other engineers who want to teach tech stuff to kids but don’t want to make the same silly mistakes that we did.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTfzCV5EHsnsNCrLa4zT8g.jpeg" /></figure><h4>What Could I Teach?</h4><p>I would imagine that mobile games would attract a lot of participants but there was just one problem: I know nothing about it.</p><p>I know about web services and other back-end technology; none of which are particularly interesting for people just starting out with programming. Could the session be about something for mobile devices without needing to deal with gaming platforms?</p><p>Interestingly enough, some messaging apps, like Kik and Telegram, have very simple APIs for developing chat bots.</p><p>This is how these APIs often work:</p><ol><li>Deploy a simple web service to some cloud service.</li><li>Acquire a (free) API key.</li><li>Implement the messaging platform’s callback interface.</li><li>All messages sent to your bot will be delivered to your web service.</li></ol><p>That is very straight-forward, and so it was decided that the topic for our talk would be developing chat bots for Kik and Telegram.</p><h4>But Why Chat Bots?</h4><p>It’s pretty simple actually: A bot can help and entertain people without them having to leave their favourite app. Sure, games are perhaps more engaging but games are also more difficult to develop. A chat bot doesn’t have to be more complicated than some simple if-this-message-then-respond-with-this-message logic. It all depends on the kind of problem the bot should solve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yV-uP5Mr6SVkHzOccjstgQ.jpeg" /><figcaption>What piques the interest of kids? Playing with other kids? Exploring unknowns? Games?</figcaption></figure><p>Now that we knew what to talk about we only needed to plan an interesting, educational, engaging and fun learning experience. I mean, how hard can it be!?</p><h3>How To Make It Engaging?</h3><p>We gave this quite a lot of thought. How could we make our session engaging, exciting and fun? Gamification seems to be hot these days. The idea here is that you want to add “game elements” into your lesson to trigger some competitive nerve among students.</p><blockquote>“Gamification is the application of game-design elements and game principles in non-game contexts.”<br><a href="https://en.wikipedia.org/wiki/Gamification">Gamification on Wikipedia</a></blockquote><p>You could read <a href="https://www.edutopia.org/blog/epic-fail-win-gamifying-learning-liz-kolb">Gamifying Learning in My Classroom</a> or <a href="https://elearningindustry.com/23-effective-uses-gamification-in-learning-part-1">Effective Uses Of Gamification In Learning</a> if your want to learn more.</p><p>We decided to try these aspects of gamification:</p><ul><li>Use the word “challenge” instead of “assignment” or “task”. A challenge is something that you need to overcome and want to solve. A task or an assignment is just something you do because someone told you to.</li><li>Give out stickers or other types of “achievement awards” when participants complete tasks. Sorry, I meant complete <em>challenges</em>.</li><li>Each challenge would, roughly, represent half an hour of the session and completing a challenge could be compared to “levelling up” in a game.</li><li>Have bonus assignments for participants who finish early.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XXjTGFVYkpd53whYGXANSA.jpeg" /><figcaption>Kids love to play games. Why would they be different from their parents!?</figcaption></figure><p>We defined, and wrote instructions for, four challenges:</p><ol><li>Getting something very simple running on localhost. No cloud server. No API keys. Just Python. This ensures that we all have a functioning development environment and shows how little coding is actually necessary to get something simple running.</li><li>Creating a Heroku account and deploying the code from the previous challenge to the cloud. This ensures that we all have the necessary tools installed.</li><li>Create a chat bot account for Kik or Telegram.</li><li>Deploy a chat bot to the cloud.</li></ol><p>Start with simple stuff and then dig deeper, basically.</p><h3>What Could Possibly Go Wrong?</h3><p>Now that we had a topic and a plan we thought it might be a good idea to account for the unexpected. We discussed what problems we might encounter during the session.</p><blockquote>“I am prepared for the worst, but hope for the best.”<br><a href="https://en.wikiquote.org/wiki/Benjamin_Disraeli">Benjamin Disraeli</a> (1804–1881)</blockquote><h4>How Much Do They Know?</h4><p>It’s hard to gauge and predict expectations and skills of participants in these kinds of lessons. Do they expect to just try things out or to be given a lecture? Do they have the prerequisite knowledge and interest or did they just chose to attend because other sessions were already full?</p><p>We chose to assume that the participants would have developed some basic Python applications but nothing else. It would have been preferable to require, or assume, some knowledge of how the web works (web servers, cloud computer and so on) but we did not expect any such knowledge.</p><p>I personally assumed that our session would attract mostly teenagers because I assume that instant messaging is used by more teenagers rather than younger kids.</p><h4>How Much Do They Want To Know?</h4><p>Should you explain every step or just tell them “do this and then do that”? Just following instructions without understanding them doesn’t do much good, in my opinion. Then it’s just mechanically performing tasks without any reflection. I guess it would be okay to just follow instructions if one later revisits the code and reflects on what it does but there is a big risk one does not take the time to do that.</p><p>In the end we chose to write our instructions with short descriptions sprinkled in here and there.</p><h4>The Show Must Go On. Let’s Scrap This Step.</h4><p>We knew that we might have to throw a lot of the planned stuff out the window because we did not know anything about the participants.</p><p>It is obviously hard and time consuming to prepare for the unexpected so we settled on acknowledging that things might have to be changed on the fly during the session.</p><h4>Dö Yöu Underständ My English?</h4><p>I am fluent in Swedish but my colleague is not. Would this be a problem?</p><p>I did not think much of this given my assumption that most participants would be teenagers. Teenagers in Sweden have been taught English in school since early years and they consume a lot of music, TV and text in English. We settled for writing the instructions in Swedish and then, if necessary, switch between English and Swedish when talking during the actual session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*zDrp9n_q8_rm4y52_LD25w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wKKVI_vd-SpaRIuCpr8dkw.jpeg" /><figcaption>Sometimes things “just happen” and you can’t do anything about it.</figcaption></figure><h3>Ok, So What Went Wrong?</h3><p>The day of the Hello World meet-up came. It was a very intense day. In the words of my teaching partner:</p><blockquote>[The day was about] the humbling experience of teaching kids how to code.</blockquote><p>Before I continue, I would like to point out that a lot of things did go according to plan during the day. However, being an engineer I tend to focus on the bad stuff. The things that annoy me. Things I know could be improved.</p><p>That being said; let me now briefly mention some things that didn’t go according to plan…</p><h4>Age Range</h4><p>The day of the lecture (or should I call it the lesson?) came and the kids arrived. I say “kids” because they were not as old as I had expected.</p><p>As previously mentioned, I expected chat bots to interest teenagers but instead our participants where more like 9–13 years old. This obviously affected how acquainted they were with “common development tasks” like using a terminal, installing applications and creating files with weird names like Procfile and .gitignore.</p><p>Pre-teens also require more attention and more explicit instructions, which forced us to be more hands-on instructors, which introduced delays.</p><p>The fact that the participants were younger than expected also affected how well we could communicate with them. The kids were surprisingly good at English and <em>most </em>of them could talk effortlessly with both of us. Having said that, I still spoke Swedish <em>most</em> of the time since it was in fact the mother tongue of the kids.</p><blockquote>Lesson Learned:<br>Try to get an idea of the participants ages before the session.</blockquote><blockquote>Lesson Learned:<br>Either only talk Swedish or make it clear during sign-up that not all instructors are fluent in Swedish.</blockquote><h4>Unusual Format For Instructions</h4><p>We had found this really <a href="http://lab.hakim.se/reveal-js/">cool library for creating web-based slide shows</a> and we used it for the slides we showed on the big screen in the room the session was held in. This worked well.</p><p>We used the same slide show tool to write the step-by-step instructions for each of our four challenges. This did not work well. The instructions had to be split into multiple slides and some participants did not immediately understand how to get to the next set of instructions.</p><p>Links to the instructions were shown on the big screen in our room. The kids could then read the instructions on their own computers by simply typing a bit.ly link. At least that was the idea.</p><p>Unfortunately it was easy to misspell the addresses and this added unnecessary confusion and frustration for something as simple as getting some instructions.</p><blockquote>Lesson Learned:<br>Do not try to be clever with instructions. Step-by-step instructions should be given in plain documents, either electronically or on paper.</blockquote><h4>Rushed Formatting</h4><p>In an effort to produce fancy slide-based instructions we didn’t have time to ensure consistent styling across all slides. This resulted in some console command being printed in a body text font whereas some were shown in a mono-spaced font. This made it hard to know what was instructions and what was source code.</p><blockquote>Lesson Learned:<br>Make sure everything follows the same style guide.</blockquote><h4>Confusion Ensues When Running Out Of Time</h4><p>We noticed quite early that we would have trouble finishing on time, or at the very least that many of the participants needed more time than expected to get started.</p><p>When more than two thirds of the session had passed we still hadn’t gotten past the halfway point. Not good. We tried to jump ahead in the plan by skipping the third task and moving on from the second to the fourth, and final, task.</p><p>This wasn’t a big problem since we had prepared one source code package for each task and each such package was self-contained in the sense that you can download any one of them and get something fully functional. However, skipping one step also meant that we had to change our instructions in the middle of the session. Not ideal.</p><blockquote>Lesson Learned:<br>It was a good idea to have pre-packaged the necessary source code for each task but in the end it didn’t matter that much since we were short on time anyway. The lesson learned is perhaps then that <strong>things always take more time than expected</strong>. We should have known this but <a href="https://youtu.be/tPT-UYd7kj4">we humans are really good at deceiving ourselves when it comes to time management</a>.</blockquote><blockquote>Lesson Learned:<br>When it started to dawn on us that we wouldn’t have time to finish all the steps we became noticeably distracted for a while and the kids obviously noticed this. This lessened their interest. The thing I take away from this is to <strong>always keep the spirit up</strong>. In our defence we did try to do that but it wasn’t enough.</blockquote><h4>Say What? This Is Not Your Computer?</h4><p>Two of the kids had trouble using their computers for one very simple reason: They have never used them before.</p><p>One participant usually used a computer with Windows but this particular day he had borrowed his father’s Mac, meaning that everything from file management to console windows was unfamiliar to him.</p><p>Another participant had borrowed a vanilla Windows tablet from Hello World which, obviously, didn’t have the required tools pre-installed.</p><p>A third participant could not connect to our office wifi. In the end we solved the problem by enabling the wifi hot-spot on my mobile phone and letting him connect to that one instead.</p><p>Additionally, some of the computers had Python but not Pip (the Python library manager). We had identified this as a potential risk but considered it to be minimal since we had tried installing Python on both Windows and Mac without running into this problem.</p><blockquote>Lesson Learned:<br>Not all participants will have read, understood or completed the prerequisites. Deal with it. Plan for it.</blockquote><h4>Wait… What Was My Username Again?</h4><p>Developing a chat bot like ours requires you to keep track of a some things:</p><ul><li>cloud platform account credentials,</li><li>your Kik or Telegram account credentials,</li><li>the bot’s own credentials.</li></ul><p>It is easy to get these confused when you are a beginner.</p><blockquote>Lesson Learned:<br>Make sure participants choose names which are guaranteed to be unique, like “helloworldklarna_alice” or “helloworld-banana”, if the task at hand requires them to create accounts with major service providers.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-fjWdd7Xkr5Emneitxi0fQ.jpeg" /><figcaption>At least the kids were focused and engaged at the beginning of the session…</figcaption></figure><h3>Will I Do Things Differently Next Time?</h3><p>I learned a lot during this experience, both during the planning stage the execution stage. Let me quickly summarise it for you.</p><h4>Lesson Structure</h4><p>The main problem turned out to be our four-challenge plan, which started from scratch and then added complexity.</p><p>This turned out to be a less than perfect idea because the initial tasks had very little to do with chat bots, just programming and web services in general, and those tasks consumed so much time that we never had time to do the last and most interesting task. <strong>The final task was the crowning jewel, the task that was absolutely necessary in order to get the chat bot running, and we ran out of time before we got there.</strong></p><p>If I get the chance to do this session again I would structure it completely different. I would start with a complete and fully functional example. Make sure everyone <em>first</em> have something fully functional up-and-running and <em>then</em> move on to describing how it all ties together.</p><h4>Adapting To Change</h4><p>How do you quickly adapt when you notice that things are taking way longer than planned? Do you accept it? Do you jump ahead?</p><p>The next time I am faced with planning a similar session I will make it easy to adapt to change during the actual session by planning it in terms of separate half-hour assignments (the “challenges”). It should be possible to get started with a challenge without having completed any other.</p><p>Everything needed to complete a specific task, including instructions and source code, should be readily available and downloadable without having to look at other assignments. This means that we can still <em>plan</em> to do tasks in a specific order but we <em>can</em> skip or reorder if necessary.</p><h4>Good Instructions Are Hard To Come By</h4><p>Handing out instructions as slides instead of documents was a bad idea: People are not used to it and it caused some confusion.</p><p>On the other hand; online slides, compared to static instructions on paper or e-mail, gave us the ability to change them on the fly when we realised that we needed to change the session.</p><p>The lesson learned is that slides are good for what you want to show to the whole class. Step-by-step instructions should be handed out as regular documents, either online or on paper. Electronic documents are probably preferable since it allows participants to copy and paste commands. Nothing of this should be news to anyone.</p><h4>Team Work</h4><p>This is a pretty small thing overall but right at the start of our little lesson we touched upon pair programming. We mentioned to the kids that we thought it would be a good idea if they could pair up and cooperate on the assignments. They were not thrilled by the idea, and I can’t blame them.</p><p>Pairing up does not work with kids who don’t know each other. This actually has nothing to do with programming but instead relates to people in general: Being in a room full of complete strangers is never fun and being asked to collaborate with them on the spot is not something everyone is okay with. Maybe next time I’ll start by asking if anyone <em>wants</em> to collaborate, pair those kids up and let the other kids work on their own.</p><p>Anyway, this was no big deal and the kids did try to help each other out when they got stuck on something, which was nice.</p><h4>The Future Of Our Society</h4><p>My final, and maybe most important, take-away from this whole teaching experience has nothing to do with the teaching experience at all. Instead it is about the brilliant kids growing up today!</p><p>The future looks really bright. The next generation of software developers (or should I say the <em>new</em> generation since these kids are already putting their applications and games out there?) will be amazing developers!</p><p>They are motivated, interested and curious. They will be, if they are not already, fluent in English. They will know how to find a solution to pretty much any problem, either by searching the web or by developing software which figures it out for them.</p><p>I’ll end with what one of the kids talked about during a break:</p><blockquote>“Could you tell me more about Klarna? Me and my friend are developing a subscription based service and we have been looking into different payment solutions but are not happy with them: We don’t like Paypal’s 30-day charge-back policies and we don’t like that Swipe cannot do recurring payments.”<br>/Hello World meet-up participant</blockquote><p>The future looks bright.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46a854c3eaca" width="1" height="1" alt=""><hr><p><a href="https://engineering.klarna.com/why-did-i-fail-teaching-programming-to-kids-46a854c3eaca">Why I Failed Teaching Programming to Kids</a> was originally published in <a href="https://engineering.klarna.com/">Klarna Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>