<?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 Medi Assumani on Medium]]></title>
        <description><![CDATA[Stories by Medi Assumani on Medium]]></description>
        <link>https://medium.com/@mediassumani49?source=rss-d5fe5a88b33a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Medi Assumani on Medium</title>
            <link>https://medium.com/@mediassumani49?source=rss-d5fe5a88b33a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 03:39:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mediassumani49/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[Understanding the UIViewController Lifecycle in iOS]]></title>
            <link>https://medium.com/@mediassumani49/understanding-the-uiviewcontroller-lifecycle-in-ios-a72a208a9b54?source=rss-d5fe5a88b33a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a72a208a9b54</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[view-controller]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Medi Assumani]]></dc:creator>
            <pubDate>Tue, 05 Apr 2022 20:23:16 GMT</pubDate>
            <atom:updated>2022-04-07T14:19:59.704Z</atom:updated>
            <content:encoded><![CDATA[<h4>A concise, handy, and comprehensive guide for iOS developers.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*etDLgjBamDJoiaM3_hie9A.png" /><figcaption>Figure 0.0: A diagram of a UIViewController lifecycle. Courtesy of <a href="https://developer.apple.com/documentation/uikit/uiviewcontroller">Apple</a>.</figcaption></figure><h3>Overview</h3><p>Almost each screen that an iPhone user sees on their phone is a <a href="https://developer.apple.com/documentation/uikit/uiviewcontroller"><em>UIViewController</em></a>, which is a class that manages the contents of that screen (buttons, images, texts, etc..), accurately calculate their sizes, responds to the user interactions (touching, dragging, long pressing), and so forth. Today I wanted to explain the most important methods that makes up the lifecycle of a <em>UIViewController</em>, that is from the second a user intends to view that screen to the moment they dismiss it. I believe it is crucial for each iOS Engineer to really understand it in order to make educated decisions as to where and when to execute a block of code when a screen is presented. Let’s get into it.</p><h3>1. init</h3><p>This is more of a OOP method rather than a lifecycle’s, but is the first that gets called immediately after a <em>UIViewcontroller</em> object has been initialized. One thing to keep in mind is that <em>init()</em> is only called once during the lifetime of its view view controller(from when created to when it is released from memory), so make sure whatever code that’s in there needs to be executed only once.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5848fb69d18e900fffed2b895ad675e2/href">https://medium.com/media/5848fb69d18e900fffed2b895ad675e2/href</a></iframe><h3>2. willMove &amp; didMove</h3><p><em>willMove()</em> is the first lifecycle method that gets triggered. This happens up until a child view controller is added to a parent/super view controller. For example, using <em>addChild()</em> to add view controller onto the current hierarchy will automatically call that child’s <em>willMove()</em> function to notify it that it’s about to be added onto the view hierarchy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/283dc5c5bc5836531b1ac7564cacdb5e/href">https://medium.com/media/283dc5c5bc5836531b1ac7564cacdb5e/href</a></iframe><p><strong>Here are a few things to keep in mind</strong>: the child view controller implementation of <em>didMove(toParent: )</em> will <strong>NOT</strong> gets triggered unless it is explicitly called by the parent class(line 7). Secondly, Calling <em>removeFromParent() </em>will trigger the <em>willMove()</em> function because it causes that view controller to transition/go to another super/parent view.</p><h3>3. loadView</h3><p><em>loadView()</em> is triggered when the the view controller’s view object is being created. When using storyboards, this is the method that will load your nib and set it to the view controller’s view object. However, if you’re setting up your User Interface programmatically, this method would simply create an empty <em>UIView</em> object and assign to the view controller’s view object. You can also override(but NOT invoke it explicitly), this method to configure your views hierarchy manually.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a37327b925cfcf31416585c0c00c980/href">https://medium.com/media/3a37327b925cfcf31416585c0c00c980/href</a></iframe><h3>4. viewDidLoad</h3><p><em>viewDidLoad() </em>is the most common and familiar lifecycle method in a <em>UIViewController</em>. When the view controller’s view object is loaded/created into memory after <em>loadView()</em> completes its execution, UIViewController tells our class “okay, this controller has a view now and is ready to be customized to our liking”. This means we can use <em>viewDidLoad()</em> to add subviews, customize other UI components(text, buttons, images), make api calls, and so so forth.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c4aff84da6c63b2eddbd2faccab04e3/href">https://medium.com/media/4c4aff84da6c63b2eddbd2faccab04e3/href</a></iframe><p><strong>One thing to keep in mind </strong>is that <em>viewDidLoad()</em> only gets called once in the entire lifetime of your <em>UIViewController</em> class, so make sure the code you put in here needs to only run once as well.</p><h3>5. viewWillAppear</h3><p><em>viewWillAppear()</em> is triggered to notify your <em>UIViewController</em> class that it’s almost ready to be made visible to the user. You can use this method to carry out extra tasks that needs to be done before the user sees the screen.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed3cdf560fa52cd4dcf1badba645e9b3/href">https://medium.com/media/ed3cdf560fa52cd4dcf1badba645e9b3/href</a></iframe><p><strong>One thing to keep in mind </strong>is that this method can be called multiple times during the lifetime of your UIViewController. An example of that is when a user switches back and forth between different tabs, which will require each view controller to <em>appear</em> each time that happens. So make sure the code you put inside this function doesn’t mind running more than once.</p><h3>6. viewDidLayoutSubviews</h3><p>Now that you’ve added your subviews, it will cause the <a href="https://www.hackingwithswift.com/example-code/uikit/whats-the-difference-between-frame-and-bounds">bounds</a> of the view controller’s view object to update. That’s when <em>viewDidLayoutSuviews()</em> gets triggered, as you will now have access to the actual x, y, width, and height of your view controller’s view. If setting up your subviews programmatically, you can override this method to update their sizing and positions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8e462c6eb16aa231b04f7fba1b5a30a/href">https://medium.com/media/f8e462c6eb16aa231b04f7fba1b5a30a/href</a></iframe><p><strong>Another thing to keep in mind</strong> is that <em>viewDidLayoutSuviews </em>can also be triggered when a user rotates their device from portrait to landscape mode(and vice versa), as that would cause the bounds of the view to update. Additionally, forcing a layout using <a href="https://abhimuralidharan.medium.com/ios-swift-setneedslayout-vs-layoutifneeded-vs-layoutsubviews-5a2b486da31c"><em>setNeedsLayout()</em> or <em>layoutIfNeeded()</em></a> will also trigger <em>viewDidLayoutSuviews() </em>to<em> </em>execute in order to adjusts accordingly.</p><h3>7. viewDidAppear</h3><p>After all the subviews are positioned, sized, and laid out on the view, <em>viewDidAppear() </em>is triggered to notify your class that the user can now visibly see everything on the screen.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ab61adc7c067022b2500f7dede57e8b/href">https://medium.com/media/6ab61adc7c067022b2500f7dede57e8b/href</a></iframe><h3>8. viewWillDisappear &amp; viewDidDisappear</h3><p>When a user is about to transition from one screen to another, <em>viewWillDisappear() </em>and<em> viewDidDisappear()</em> gets called to notify the current view controller that it will soon be dismissed. This can be a great place to do any clean up(i.e: cache specific to this view controller) or cancel any pending or long running tasks(api request, queued job, etc…).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b8d56ceb134f2c47c4b812c243e2201/href">https://medium.com/media/2b8d56ceb134f2c47c4b812c243e2201/href</a></iframe><h3>9. deInit</h3><p>Just like <em>init()</em> is the first method to get called, <em>deinit(</em>) is the last one as it notifies your view controller class that it has been removed and released from memory.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ad843133fecf35a7f8108c1f808dc19/href">https://medium.com/media/9ad843133fecf35a7f8108c1f808dc19/href</a></iframe><p><strong>Here are a few things to keep in mind</strong>: If the code within your <em>deinit()</em> method never gets called(aka your view controller never gets deallocated), there is a very good chance you have a <a href="https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html">retain cycle</a>. Your view controller is strongly referenced in a closure, by a protocol, or by another class that’s still alive. Another thing to keep in mind is that you need to be very careful about accessing a class property within the <em>deinit()</em>, as at that point that property might be nil, cause a race condition, or crash your app.</p><h3>Conclusion</h3><p>There you have it. I’d strongly encourage you to dig into the <a href="https://developer.apple.com/documentation/uikit/uiviewcontroller">official UIViewController documentation</a> from Apple or the <a href="https://github.com/apple/swift">Swift open sourced code on Github</a>. There are other methods and properties that have not been mentioned in this article but are just as important. Thanks for reading, If you learned a thing or two in this article, don’t forget to support by <a href="https://help.medium.com/hc/en-us/articles/115011350967-Claps#:~:text=To%20clap%20for%20a%20post,much%20you%20liked%20the%20story.">leaving some claps</a> 👏 or leave a comment below with any questions you might have.</p><blockquote>About the Author :</blockquote><blockquote>Hi, I’m Medi! I enjoy writing about swift, iOS development, and tech in general. I work at <a href="https://tech.buzzfeed.com/">BuzzFeed</a> as an iOS Engineer and studied computer science. You can get in touch with me through <a href="http://mediassumani49@gmail.com/">email</a> , <a href="https://www.linkedin.com/in/medi-assumani/">LinkedIn</a>, or <a href="https://github.com/mediassumani">Github</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a72a208a9b54" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Objective-C for Swift Developers]]></title>
            <link>https://medium.com/swlh/objective-c-for-swift-developers-ca8196e914ff?source=rss-d5fe5a88b33a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca8196e914ff</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[objective-c]]></category>
            <dc:creator><![CDATA[Medi Assumani]]></dc:creator>
            <pubDate>Fri, 26 Feb 2021 19:01:05 GMT</pubDate>
            <atom:updated>2021-06-08T21:20:08.100Z</atom:updated>
            <content:encoded><![CDATA[<h4>A basic guide for iOS Developers who primarily work with Swift.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KZzd3G4nHP4g1DSVOzEn-A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@karlp?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Karl Pawlowicz</a> on <a href="https://unsplash.com/s/photos/developer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Overview</h3><p>If you started your iOS Development learning journey after 2014, you might be more familiar with <a href="https://developer.apple.com/swift/">Swift</a>; Apple’s beloved programming language for their iOS, iPad OS, Apple OS, and TV OS operating systems. This is fine because most Mobile Engineering teams prefer to work with it due to its developer-friendly syntax, enriched APIs, and low learning curve. In this article, I’m going to share some basic concepts that can help you work on a codebase that has a mixture of Objective-C and Swift(this is extremely common for most iOS Applications).</p><h3>Quick Agenda</h3><ul><li>Differences between Swift &amp; Objective-C.</li><li>Basic Objective-C concepts.</li><li>Intermediate Objective-C concepts.</li></ul><h3>Differences</h3><p>Let’s first see a few ways that both languages differ(these are just a few ones):</p><ol><li>Since Objective-C inherits the C language, you need to keep track of both a header file(the “h” file) and an implementation file(the “m” file). Swift only requires a single file to define and implement a class.</li><li>Objective-C uses a combination of static and dynamic typing, meaning that the majority of types of objects are declared at compile type.</li><li>In Objective-C, mutability is limited by certain classes and property attributes, and by default, all objects are mutable. NSString, NSArray, NSDictionary, NSSet are not mutable, To mutate objects of that type, you must use NSMutableString, NSMutableArray, NSMutableDictionary, etc.</li><li>Swift uses the standard true/false for its boolean evaluation, while Objective-C uses a combination of YES/NO and Boolean type.</li><li>Objective-C requires a semicolon at the end of each statement(yeah, that annoying thing🙃) while Swift does not.</li><li>Swift has the concept of <a href="https://www.swiftbysundell.com/basics/type-inference/">type inference</a>, while Objective-C requires you to explicitly declare the data type of a variable.</li></ol><h3>Basic Concepts</h3><p>Now that we’ve seen how Objective-C differs from Swift, let’s take a look at some basic concepts that’ll get you familiar with its ecosystem.</p><h4>1. Variables &amp; Printing Statement</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04734d3f4c3612d7b3f36633ad69eed8/href">https://medium.com/media/04734d3f4c3612d7b3f36633ad69eed8/href</a></iframe><h4>2. Primitive Data Types</h4><p>Like many other programming languages, Objective-c has its main primitive data types. They are(maybe be missing a few but these are the core of it):</p><ul><li>char</li><li>boolean</li><li>int</li><li>float</li><li>double</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de799a080ff7910fb6e333ccb86a5019/href">https://medium.com/media/de799a080ff7910fb6e333ccb86a5019/href</a></iframe><h4>3. Function Declaration</h4><p>Another major difference between the two languages is how we declare and define functions. Swift has very clean and intuitive function definitions such as <a href="https://kotlinlang.org/docs/basic-syntax.html#functions">Kotlin</a>, whereas objective-c takes precedence of languages such as C/C++.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4007d3abb0d20431d070d7be87448519/href">https://medium.com/media/4007d3abb0d20431d070d7be87448519/href</a></iframe><h3>Intermediate Concepts</h3><h4>1. Object-Oriented Programming</h4><p>While the core principles of Object-oriented Programming remain the same in Objective-C, there are a few things that take a slightly different approach. Objective-c takes the concept of a header(also known as h-file) and implementation(also known as m-file) file. The idea here is that we have one file for just <strong>declaring</strong> our class(the name, the properties, and methods) and the other for <strong>implementing </strong>our class. Let’s take a closer look:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7935529876b4911ad1b45704fb2d83ba/href">https://medium.com/media/7935529876b4911ad1b45704fb2d83ba/href</a></iframe><p>The actual implementation of the class will look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ee6dda6d57750f9f4d1494543714d33/href">https://medium.com/media/0ee6dda6d57750f9f4d1494543714d33/href</a></iframe><p>The next step is to declare and manipulate the instance of the class above:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e2a97a2d48f9e06a8fe27d3197a1691/href">https://medium.com/media/9e2a97a2d48f9e06a8fe27d3197a1691/href</a></iframe><h4>2. Enums</h4><p>Every enum is of type NSInteger and there is no “case” keyword to represent each property.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c945261c3a00b2dacde41c3cd86a5a32/href">https://medium.com/media/c945261c3a00b2dacde41c3cd86a5a32/href</a></iframe><h4>Conclusion</h4><p>As you just read, there are some significant differences between Objective-C and Swift. Though it might feel unnecessary to learn Objective-C when Apple fully supports Swift as its primary programming language, I believe doing so can help you in a few ways, one being that most mobile applications were built out pre-swift, meaning that their core and legacy functionalities and files such as the AppDelegate are still in Objective-C. Thanks for stopping by! If you learned a thing or two in this article, don’t forget to support by <a href="https://help.medium.com/hc/en-us/articles/115011350967-Claps#:~:text=To%20clap%20for%20a%20post,much%20you%20liked%20the%20story.">leaving some claps</a> 👏</p><blockquote>About the Author :</blockquote><blockquote>Medi is a Software Engineer specialized in Mobile iOS development. He enjoys writing about Swift, iOS dev, and Tech in general. You can get in touch with him through his <a href="http://mediassumani49@gmail.com/">email</a> or <a href="https://www.linkedin.com/in/medi-assumani/">LinkedIn</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca8196e914ff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/objective-c-for-swift-developers-ca8196e914ff">Objective-C for Swift Developers</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy and Open-Source a Swift Library]]></title>
            <link>https://medium.com/@mediassumani49/how-to-deploy-and-open-source-a-swift-library-33622424802e?source=rss-d5fe5a88b33a------2</link>
            <guid isPermaLink="false">https://medium.com/p/33622424802e</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[cocoapods]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Medi Assumani]]></dc:creator>
            <pubDate>Sat, 09 May 2020 07:01:01 GMT</pubDate>
            <atom:updated>2021-06-16T22:12:17.694Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to open source your first swift library via Cocoapods</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nh7FQmvgk6UABB1O7z9zVg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@mimithian?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Mimi Thian</a> on <a href="https://unsplash.com/s/photos/developer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Overview</h3><p>Open source source software is all about sharing reusable and trusted code to prevent reinventing the wheel. For example, thanks to libraries such as <a href="https://github.com/fastlane/fastlane">fastlane,</a> we don’t have to manually release applications or build our own custom release automation tool, which can costs a lot of engineering hours and resources. In this article, I’m going to walk you through how to build, deploy, and open-source a swift library via <strong>cocoapod</strong>.We will mainly talk about:</p><ul><li>Dependency Managers</li><li>Hosting Options</li><li>Setting Up Xcode</li><li>Test Coverage</li><li>Configuring a Podespec file</li><li>Uploading to Github</li><li>Publishing to Cocoapod</li><li>Setting up your Readme.</li></ul><h3>Dependency Managers</h3><p>The major component of any open sourced library is the ability to distribute it to other developers. That process is automated by a tool known as a <strong>package/dependency manager</strong>. Some of the most widely known open-sourced package managers are <strong>npm</strong>(javascript), <strong>pip</strong>(python), <strong>homebrew</strong>(macOS), <strong>dep</strong>(go), etc…. For swift or objective-c, we have three options: <a href="https://cocoapods.org/"><strong>Cocoapod</strong></a> and <a href="https://github.com/Carthage/Carthage"><strong>Carthage</strong></a>.</p><h4>Cocoapod</h4><p>Cocoapod is a dependency manager written in ruby, that can help you install, update, and maintain one or more libraries within your Xcode project. When someone would like to use your library in their project, all they have to do is add it to the Podfile and run “pod install” in the terminal.</p><h4>Carthage</h4><p>Carthage is an alternative to cocoapod and widely used in the industry. The main thing about it is that it <strong>runs, builds, and converts your dependencies into binary frameworks</strong>. You can read more about the difference between carthage and Cocoapod <a href="https://www.codementor.io/blog/swift-package-manager-5f85eqvygj">here</a>.</p><p><strong>NOTE</strong>: For this tutorial, we will choose Cocoapod as our dependency manager of choice. Keep in mind that libraries in the iOS world are known as Pods, as you will see mentioned throughout this article</p><h3>Hosting Options</h3><p>Before we get into how we can distribute our library, we need to decide where our actual <strong>codebase will live(hosted)</strong>. This will help Cocoapod to know where to pull the library from. There are two main options for this task: <a href="https://github.com/"><strong>Github</strong></a> or <a href="https://bitbucket.org/product"><strong>Bitbucket</strong></a>. For this tutorial, we will go with Github as our hosting choice. Go ahead and create a new (public) repository. Once created, clone that repository in your local computer by running the command:</p><pre>&gt; git clone <a href="https://github.com/alixc/ShazamLite.git">https://github.com/</a>yourHandle/yourRepoName.git</pre><h3>Setting up Xcode</h3><p><strong>Step 1</strong>: Lets’ create a new Xcode project within that repository(folder) you just cloned. Make sure to select “Framework” as our type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dAfYpR3GKWisVZZ2WOZswg.png" /></figure><p><strong>Step 2</strong>: Enter the name of your library and select the language to write it in. iOS libraries can be written in Objective-C or Swift as they <strong>both compile to the machine language</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*r4mbGIkx8QnbL5hyZN-9RQ.png" /><figcaption>Go ahead and tick the “Unit Tests” box if you’d like to add test coverage.</figcaption></figure><p><strong>Step</strong> <strong>3</strong>: Create a source file. This is where your actual code will go into. For the sake of the tutorial, I’ll keep my library very simple with just one class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6h_uPN7-zeoKfPJNP5q-A.png" /><figcaption>A normal library wouldn’t typically be this small. They’re usually made up of many classes that work together.</figcaption></figure><h3>Test Coverage</h3><p>Ideally, we’d like to have some test coverage for the code you’ve just written. It makes sure that the code that you’re sharing with hundreds of developers is robust and reliable. We’d then hook it up with a continuous integration service, such as <strong>TravisCI</strong> or <strong>CircleCI</strong>, in order to stay up to date with the build status of each release. However, that is beyond the scope of this article. You can refer to <a href="https://www.raywenderlich.com/1618-travis-ci-tutorial-getting-started">this article from Raywenderlich</a> if interested.</p><h3>Configuring a Podspec File</h3><p>Before we are able to ship our library, we need to add a configuration file that carries extra informations about it. You can think of it as <strong>.travis.yml for TravisCI</strong> or <strong>dockerfile for Docker</strong>. It’s a simple yet powerful configuration file that encapsulates basic information such as the name, the version, its location on Github, and more. For Cocoapod, it’s the <strong>.podsec</strong> file. Run the following commands to create your .podsec file:</p><pre>&gt; pod spec create yourAwesomePodName<br>&gt; open yourAwesomePodName.podspec</pre><p>This is an example of how your .podspec file should look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b61e0eec66f9a387cc2933d8c1d35754/href">https://medium.com/media/b61e0eec66f9a387cc2933d8c1d35754/href</a></iframe><h3>Uploading to Github</h3><p>Ok we’re almost there! Once you’ve written the logics of your library and set up your .podspec file, go ahead and push it to Github. If you have other libraries(or pods) that you depend on, make sure to include the /Pods folder in a .gitignore file to prevent it from being uploaded to Github.</p><pre>&gt; git add .<br>&gt; git commit -m &quot;Initial commit of my wonderful library&quot;<br>&gt; git tag 1.0 <br>&gt; git push -u origin master --tags</pre><h3>Publish to CocoaPod</h3><p>Once your library is up and running on Github, the last step is to link it up with Cocoapod in order for other developers to be able to install it via the <a href="https://guides.cocoapods.org/terminal/commands.html">CLI</a>. Run the following commands to push it out to Cocoapod:</p><pre>&gt; pod repo add yourAwesomePodName [path to your Github repository]<br>&gt; pod repo push yourAwesomePodName yourAwesomePodName.podspec</pre><h3>Setting up The Readme</h3><p>Lastly, we need to add clear and straightforward documentations. This can immensely help other developers to make sense of what your library is all about. Let’s take a quick look at how we can structure our readme.md file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0bb60fc5a5d2c59df7a9c1aaea4ebe0f/href">https://medium.com/media/0bb60fc5a5d2c59df7a9c1aaea4ebe0f/href</a></iframe><p>You can check out readmes of popular open-sourced softwares such as <a href="https://github.com/Alamofire/Alamofire">Alamofire</a>, <a href="https://github.com/onevcat/Kingfisher">Kingfisher</a>, or <a href="https://github.com/pixeldock/RxAppState">RxAppState</a>.</p><h3>Conclusion</h3><p>Congratulations🎊 You’ve just built, deployed, and open-sourced your library to the entire iOS developer community! I hope you’ve found this article helpful. If you did, please don’t forget to leave some claps👏🏾, share it with others, and checkout one of my library, <a href="https://github.com/MediBoss/ShazamLite">ShazamLite</a>, on Github!</p><blockquote>About the Author :</blockquote><blockquote>Medi is a Software Engineer specialized in Mobile iOS development. He enjoys writing about Swift, iOS dev, and Tech in general. You can get in touch with him through his <a href="http://mediassumani49@gmail.com/">email</a> or <a href="https://www.linkedin.com/in/medi-assumani/">LinkedIn</a>.</blockquote><p>📝 Save this story in <a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text">Journal</a>.</p><p>👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. <a href="https://usejournal.com/newsletter/noteworthy-in-tech/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_text">Read the Noteworthy in Tech newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33622424802e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intro to Push Notifications in Swift]]></title>
            <link>https://medium.com/better-programming/intro-to-push-notification-in-swift-b2c5e21a07cf?source=rss-d5fe5a88b33a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2c5e21a07cf</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Medi Assumani]]></dc:creator>
            <pubDate>Fri, 01 May 2020 04:51:19 GMT</pubDate>
            <atom:updated>2021-06-08T21:29:44.936Z</atom:updated>
            <content:encoded><![CDATA[<h3>How Push Notifications Work in iOS</h3><h4>Add push notifications to your app</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WcDgNHyaRvkPq3MyocAFWg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jamie452?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jamie Street</a> on <a href="https://unsplash.com/s/photos/notification?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Overview</h3><p>In this article, I’m going to walk you through how to create push notifications and integrate them into your app. We will mainly talk about:</p><ul><li>Importance of push notifications</li><li>Components of push notifications</li><li>Types of push notifications</li><li>Handling notification tap</li></ul><h3>Importance of Push Notification</h3><p>Push notifications are all about getting your users to take action within your app when something happens. Think of applications like Instagram or Medium, where you get a notification every time someone likes your photo or leaves a comment on your recent article. But most importantly, this is why should you care about it as a software/product engineer:</p><h4>Engagement + retention</h4><p>You want your app to be interactive and fun for your users. In order for you to keep that interest going, you can curate a list of good content and send it via push notifications (don’t spam!) to have the users return and engage with your app. You don’t want them to just use it once and leave.</p><h3>Components of Push Notification</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*p2a5A23d0sbztOva1L2YUw.png" /></figure><p>Now let’s take a look at the different components that make up push notification in Swift.</p><h4>The user notifications framework</h4><p>At the heart of it, is the <a href="https://developer.apple.com/documentation/usernotifications">UserNotifications</a> framework, which directly works with the OS level clocks and settings to coordinate all the push notifications from different apps within a device.</p><h4>The content</h4><p>As the picture above shows, we need to let the system know what to actually show our users. This refers to the title, the subtitle, the body, and the sound of the notification. This is configured by the UNMutableNotificationContent() class. Let’s take a closer look at how we can create this object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7d2ff83b8a933decd5f16b3be7a375f/href">https://medium.com/media/e7d2ff83b8a933decd5f16b3be7a375f/href</a></iframe><h4>The trigger</h4><p>Sometimes we might need our app to send a push notification at a certain date or time. Let’s take the Google calendar app, for example. You get a push notification 15 minutes before an event or at a specific time of the event. In this case, the OS clock system needs to know when and how to send your push notification. You can do so by creating an UNCalendarNotificationTrigger object. Let’s see an example below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70e1cd20567fdcbaf7fb5970e4147e7b/href">https://medium.com/media/70e1cd20567fdcbaf7fb5970e4147e7b/href</a></iframe><h4>The request</h4><p>Built from the UNNotificationRequest() class, it takes in the content and trigger object. One thing to keep in mind is that the trigger, from the UNCalendarNotificationTrigger class<em>,</em> is optional. This is because sometimes you might want to send action-based notifications rather than time-based ones. Let’s take a quick look at the code snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/618eedb9460a810035eafa1a901053be/href">https://medium.com/media/618eedb9460a810035eafa1a901053be/href</a></iframe><h4>The action(s)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*1mDUGaquuvSOLNoln6rmIQ.png" /><figcaption>When a user presses and holds a notification, they are able to see which actions they can perform right away.</figcaption></figure><p>Sometimes, you may want to send a notification that requires a user to take an action, such as making a purchase, validating a code, or importing a document. This is a great way to minimize the steps that a user would normally have to take to perform that action if they were to normally launch the app and proceed. This is handled by two classes: UNNotificationAction and UNNotificationCategory. Let’s take a look:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afe425d7e8fcfa2b2044b556db2cad89/href">https://medium.com/media/afe425d7e8fcfa2b2044b556db2cad89/href</a></iframe><h3>Types of Push Notification</h3><h4>Action-based</h4><p>This refers to notification that must be sent out when a user performs a key action within the app. Let’s take a look at how we can create a method that sends a push notification when someones clap on your Medium article.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a479d0f7b098227c85022db5a0e634a/href">https://medium.com/media/0a479d0f7b098227c85022db5a0e634a/href</a></iframe><h4>Time-based</h4><p>The next type of push notification we will look at is scheduling. Think of an alarm clock that makes a sound and shows a banner when you wake up or the daily notification from Medium you get every morning at 8 a.m. If you’re building an app that needs some type of reminder or action at a certain time, scheduled notification is the way to go.</p><p>Let’s take a look at how we can configure a scheduled push and how it’s different from a regular push.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a0b20b1fcff0ebe301a96cd0ae8fb69/href">https://medium.com/media/2a0b20b1fcff0ebe301a96cd0ae8fb69/href</a></iframe><h3>Handling Notification Tap</h3><p>Lastly, let’s look at how we can set up our app to have custom logic when a user taps on a given push notification. Keep in mind that if you don’t properly handle your notifications, the app will simply launch when a user taps on it.</p><p>There are two methods of <a href="https://developer.apple.com/documentation/usernotifications">UserNotifications</a> that you should add in the AppDelegate<strong> </strong>(must conform to UNUserNotificationCenterDelegate)<strong><em> </em></strong>in order to do this:</p><ul><li><a href="https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter">willPresent</a>: This gets called when a notification arrives while the app is in the foreground.</li><li>didReceiveNotificationResponse: This gets called when the user taps on the notification.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cccf42fb9218056c472c13d1a111260/href">https://medium.com/media/7cccf42fb9218056c472c13d1a111260/href</a></iframe><h3>Conclusion</h3><p>I hope you’ve found this article helpful in some way. There are a couple of things we did not cover, such as <a href="https://developer.apple.com/documentation/usernotificationsui/customizing_the_appearance_of_notifications">remote</a> and <a href="https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server">rich</a> notifications. Let me know if you’d be interested to read about them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2c5e21a07cf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/intro-to-push-notification-in-swift-b2c5e21a07cf">Intro to Push Notifications in Swift</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Tips to Navigate a New Codebase]]></title>
            <link>https://medium.com/@mediassumani49/5-tips-to-navigate-a-new-codebase-91b72e986b36?source=rss-d5fe5a88b33a------2</link>
            <guid isPermaLink="false">https://medium.com/p/91b72e986b36</guid>
            <category><![CDATA[codebase]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ramp-up]]></category>
            <dc:creator><![CDATA[Medi Assumani]]></dc:creator>
            <pubDate>Sun, 02 Feb 2020 05:15:02 GMT</pubDate>
            <atom:updated>2020-02-02T05:15:02.263Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to effectively and quickly ramp upon a new codebase</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*f1k_5gp8o-yJLbRS" /></figure><h3>Overview</h3><p>Whether you are joining your first or fifth engineering job, It is quite likely that you’ll be adding new code in the company’s platform, rather than starting from scratch. <strong><em>There is a huge difference between working on an enterprise level codebase, and contributing on personal or small group project</em></strong>.</p><p>One being that it will most likely be extremely vast and incomprehensible at first; with thousand lines of code and many different modules (small or big) written in different languages/framework . In this article, I’ll provide a few tips and tricks I’ve learned on how to effectively navigate a new codebase to ramp up quickly and become a frequent contributor in your team.</p><h3>1. Review Technical Design Docs</h3><p>Every software system; whether it’s a mobile, desktop, web application; all started with an idea which was thought through on how to be implemented. In the tech industry, these are known as technical design documents. It’s where the initial engineer(s) of a module or micro-service <strong><em>dump their whats, whys, and hows when building something from scratch in words and diagrams, rather than code</em></strong><em>.</em></p><p>If you find yourself working on a part of the codebase you’ve having a hard time understanding, ask your teammate or your manager where you can find the technical design docs of that particular module. One additional thing to note is that <strong>it usually has high level sketches on how the system was designed and how the main components interact with each other.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*jcNAWx1TAejnAFi5oqB75g.png" /><figcaption>Example of a simple(not very accurate) diagram you may find in a tech design doc.</figcaption></figure><h3>2. Approach it Actively, not Passively</h3><p>Just like learning to code, you can’t really do much (or fast) by merely watching tutorials or reading books, you have to make things. This is why your first couple of tickets when you start could set you up for success or failure during your onboarding journey.</p><p>Ask your manager to work on a bug fix or small feature that will expose you to the codebase as early as possible; or perform any type of activity with your teammates such pull request reviews that can throw you out there to learn the code base actively, rather than passively reading line by line.</p><h3>3. Identify Your Turf</h3><p>If you are hired as a Backend Engineer, you might not have to worry about the client side codebase. Or if the infrastructure is composed of many micro-services that interacts with each other, you might only need to focus on some of them. Do not get too caught up in trying to understand all moving parts of your company codebase at the beginning. This will save you plenty of time to focus on the part you are expected to make direct contributions at first, then you can expend later on after ramping up.</p><h3>4. Perform Regular Code Reviews</h3><p>Code reviews can be done through comments on a pull request, in-persons chat, or via a remote video chat. You can do it with a fellow engineer, your engineering manager, or any one else who is familiar with that codebase. The reason why it’s important is because your coworker can act as a guide during your onboarding journey and help unblock you or suggests a different way to structure your code to meet the team’s standards or style guide.</p><h3>5. Leverage Your Dev Tools</h3><p>Unless you use text editor embedded within your terminal such as vim or nano(…ahem 🤭), many modern IDEs comes with a suite of nifty tools that lets you search up a function, see where it’s being called, find the file it’s been declared into, as well as reading the documentations. You can also use breakpoints and print statements while running your code to identify what each functions and objects are meant to do in runtime.</p><h3>Conclusion</h3><p>One last thing I’d like to point out is that you should not feel too overwhelm to understand everything at first. It takes about 2 to 3 months to fully onboard an engineer and become a frequent contributor to the team. So I hope you get to read this before you start your new job and find this somewhat helpful😄!</p><blockquote>About the Author :</blockquote><blockquote>Medi is a Software Engineer specialized in Mobile iOS development. He enjoys writing about Swift, iOS, Productivity, and Tech in general . You can get in touch with him through his <a href="http://mediassumani49@gmail.com/">email</a>, <a href="https://www.linkedin.com/in/medi-assumani/">LinkedIn</a> or <a href="https://www.makeschool.com/portfolio/mediassumani">Portfolio</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91b72e986b36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My first month as a Software Engineer]]></title>
            <link>https://medium.com/@mediassumani49/my-first-month-as-a-software-engineer-b8b10cd43505?source=rss-d5fe5a88b33a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8b10cd43505</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Medi Assumani]]></dc:creator>
            <pubDate>Wed, 30 Oct 2019 01:32:17 GMT</pubDate>
            <atom:updated>2019-10-30T02:48:34.655Z</atom:updated>
            <content:encoded><![CDATA[<h4>Navigating my new job as a Software Engineer in San Francisco</h4><h3>Overview</h3><p>It’s been over a month now since I’ve joined <a href="https://www.stridehealth.com/">Stride</a> as a Software Engineer working on the Mobile team. At Stride, we build a suite of “Benefits for Independents,” connecting self-employed workers with health insurance, health care, and tax compliance support.<em> </em>I&#39;ve thoroughly enjoyed my work so far and wanted to share what my experience has been so far. Here’s a little agenda on what I’ll be talking about:</p><ol><li>Getting into Tech</li><li>The First Day</li><li>Setting Up my dev environment</li><li>My role/position</li><li>My team</li><li>My first ticket</li><li>Conclusion</li></ol><h3>Getting into Tech</h3><p>I graduated high school in 2017 in a small township in New Jersey, where I had my first intro to coding during my junior year. I knew by then that I wanted to get into tech but did not know how broad the industry was. After attending Saint Peters University for a year as a computer science major, I had noticed that the traditional way of learning was not applicable to me.</p><p>I then dropped out and decided to join <a href="https://www.makeschool.com/">Make School</a> in August 2018, which was then a 2-year coding Bootcamp located in San Francisco. There, I had studied iOS and backend development because I wanted to learn how to build real-time and well-designed applications that brought values to users. During my 1-year tenure there, I learned many programming languages and web frameworks including Swift, Python, Javascript, Node, Django, and more.</p><p>I then left Make School in September 2019 after accepting a full-time offer from an amazing and mission-driven start-up called <a href="https://www.stridehealth.com/">Stride Health</a> in San Francisco as a Software Engineer developing the company’s <a href="https://www.stridehealth.com/tax">Mobile Application</a>!</p><h3>The First Day</h3><p>From the moment I had accepted my offer to when I was handed my badge, I still couldn’t believe it. It was a dream coming true after a full year of non-stop grind at the Bootcamp. On the first day, I arrived in the office at 9:45 am, casually dressed, and was shown to my desk that was already packed with swags and goodies. New MacBook pro, dell monitor, Stride T-shirts, etc…I spent half the day onboarding and learning about different policies and values of the company. I then had several 1:1s meetings with my manager, Sr. Engineers, and different other co-workers from Marketing, People Ops, Design, Product, etc…</p><h3>Setting up my dev environment</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qYboEaMQLOSY21tJnIrOCg.jpeg" /><figcaption>My desk set up at Stride. I use my laptop for Chrome/Slack/Spotify, middle screen for Xcode, and right monitor for iTerm 2</figcaption></figure><p>On my first day, I was given a list of software and tools I needed to set up on my new laptop to get up and running. The first thing I had to install was <a href="https://github.com/Homebrew/brew">brew</a>, then <a href="https://www.iterm2.com/">iTerm 2</a>, followed by <a href="https://git-scm.com/">git</a>. Although it was my first full-time job, I was pretty familiar with those tools and their configurations as I’ve extensively worked with them at Make School.</p><p>I also had to install a few internal tools we use for development, analytics, and collaborations such as <a href="https://developer.apple.com/xcode/">Xcode</a>, <a href="https://www.atlassian.com/software/jira">Jira</a>, <a href="https://slack.com/">Slack</a>, <a href="https://amplitude.com/">Amplitude</a>, and many others. Xcode is used as the main interface to our iOS app, Amplitude for Analytics, Slack for internal communication, and Jira as our ticketing system.</p><h3>My Role/Position</h3><p>At Stride, I am an iOS Engineer, meaning I mainly work on our iOS application that you can find on the <a href="https://apps.apple.com/us/app/stride-benefits-for-less/id1041591359">AppStore</a>. I mainly write code in Swift when adding new features in the app and Objective-C when refactoring a piece of legacy code. I use a bunch of other software daily to get my work done such as iTerm 2, Jira, Git &amp; Github, Postman, Amplitude, Braze, etc…</p><p>Although at work I do iOS development stuff, I like to spend my weekends exploring different other areas of software engineering, through physical books, online courses on Udacity, or through my peers. For example, I am currently learning <a href="https://graphql.org/">GraphQL</a>, which is an alternative way of building APIs.</p><h3>My Team</h3><p>In the field of technology, it is almost always the case that you’d be put into a team. The engineering team is composed of Front End, Back End, Mobile, Infrastructure, and Dev Ops engineers. The team I am part of is called Engagement, which is composed of 2 iOS Engineers, 2 Android Engineers, 1 Project Manager, 1 Product Designer, and 1 Backend/Dev Ops Engineer. My team primarily focuses on building, scaling, and upgrading on our Mobile Applications. I truly enjoy working on cross-functional teams because you get to interact with different aspects of the product!</p><h3>My First Ticket</h3><p>I was not expecting my first few tasks to be extremely challenging, but it was rather exciting. I essentially had to update our crash logs for our analytics reporting tool within the codebase. It was a great starting point because I had to parse thousands of lines of codes and look up different modules that were logging crashes. It was a lot more like a scavenger hunt, a scary yet exciting one. One of the biggest challenges I had faced was that about 25% of our codebase is written in Objective-C; Apple’s old programming language.</p><p>By the end of my fourth day, I had submitted my first pull request that contained the changes that I worked on. Although it was rejected(3rd attempt was a success🎉), it was still a very proud moment!</p><h3>Conclusion</h3><p>I’m super grateful and happy with the work I get to do as a Software Engineer at Stride. It has been both rewarding and challenging because every key decisions my teammate and I make, directly impacts our users. I’m happy to be working at a place where I’ve found a sense of purpose and meaning in my work that is beyond a salary. I hope you’ve enjoyed reading this article and check out more of my writings <a href="https://medium.com/@mediassumani49">here</a>!</p><blockquote>About the Author :</blockquote><blockquote>Medi is a Software Engineer specialized in Mobile iOS development. He enjoys writing about Swift, iOS, Productivity, and Tech in general . You can get in touch with him through his <a href="http://mediassumani49@gmail.com/">email</a>, <a href="https://www.linkedin.com/in/medi-assumani/">LinkedIn</a> or <a href="https://www.makeschool.com/portfolio/mediassumani">Portfolio</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8b10cd43505" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multithreaded Programming in iOS]]></title>
            <link>https://medium.com/@mediassumani49/multithreaded-programming-in-ios-9de206afa620?source=rss-d5fe5a88b33a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9de206afa620</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Medi Assumani]]></dc:creator>
            <pubDate>Mon, 16 Sep 2019 21:34:54 GMT</pubDate>
            <atom:updated>2019-09-30T15:05:57.298Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn which API to use for multithreaded programming in iOS.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*poitd9MXX5sB23O9qgoAwA.png" /></figure><p>Speed, performance, and responsiveness become essential factors when working on enterprise-level applications. They also play a major role in the user experience, which in turn may yield positive or negative user retention outcomes. But how do we make our apps perform faster? <strong>Multithreading</strong>! This term refers to the ability of an operating system(iOS or macOS in our case) to use its many cores and threads to perform multiple tasks simultaneously. In this article, <strong>we will solely look into two main multithreading APIs provided by apple: GCD and Operation</strong>.</p><h3>Disclaimer &amp; Note</h3><p>For this article, I am going to assume that the intended reader has a basic understanding of multithreading concepts such as process, thread, task, race condition, semaphores, and more. Let’s get into it!</p><h3>Apple’s Multithreading APIs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*70fTVWSO_nqER3fa.png" /></figure><p>Apple provides 2 main APIs for writing multithreaded code: Grand Central Dispatch(GCD) and Operation. Behind the scenes, they use a concept known as <strong><em>thread pool, </em></strong>meaning that those API manages a large number of threads and when a task is ready to be executed, it grabs one thread from the pool to take care of the task. Now let’s dig deeper into both of those APIs.</p><h3>Grand Central Dispatch(GCD)</h3><blockquote>“Grand Central Dispatch is a technology developed by Apple Inc. to optimize application support for systems with multi-core processors and other symmetric multiprocessing systems” _ Wikipedia</blockquote><p>That’s a pretty intense definition right there, let’s break it down a bit. Remember when we talked about how threads are responsible for executing tasks, well iOS developers <strong>had to interact with the Thread class directly to set them up.</strong> In the release of iOS 4, Apple decided to build a wrapper that extracts all the low-level components of multithreaded systems from the developers into a sweet and powerful API, GCD. It uses a concept of <a href="https://www.tutorialspoint.com/data_structures_algorithms/dsa_queue">Queue</a> to organize the order at which tasks are submitted to threads for execution.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6fcdd795e526224efd00a9f34491a563/href">https://medium.com/media/6fcdd795e526224efd00a9f34491a563/href</a></iframe><h3>Operation</h3><p>Operation is the second API provided by Apple to write concurrent applications. It is to be noted that <strong>Operation is built on top of GCD and is recommended over GCD</strong> by apple due to its higher level of abstraction.</p><p>One thing to keep in mind is that the Operation class is<strong> abstract,</strong> meaning that you must create a custom class that inherits it and overrides the main function. Inside the main function, you can write the logic of the operation. Below is an example of a simple Image download operation:</p><pre>class ImageDownloader: Operation { </pre><pre>       // Designated initializer<br>       init() {</pre><pre>        // You can initialize some data here    <br>       <br>       }        </pre><pre>        // Override the main function of the Operation class    <br>        override func main() {</pre><pre>        // Write the logic of the operation here   <br>       }<br>}</pre><h3>Compare &amp; Contrast</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*fhYpzxGyaGF-LFiolSZd6Q.png" /></figure><p>GCD uses callbacks mechanism to group a block of code that needs to run asynchronously on a given thread using <strong>DispatchQueues</strong>. The system uses a mechanism to prioritize running tasks known as <strong>Quality Of Service</strong>(QoS)(e.g: user interactive, default, utility, etc…). One of the most common task in iOS that uses GCD is a simple network request to a remote server on a background thread that returns valid data which updates the UI on the main thread.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ejyjak05Ci4lM4RARP0UWw.png" /><figcaption>Example of how a simple networking layer works with threads.</figcaption></figure><p>On the other hand, Operation API gives more control to developers such as controlling the <strong>max number of concurrent tasks to run simultaneously</strong>, pass <strong>priority levels</strong> to each execution and control the flow of the operation(<strong>pause, resume, and cancel</strong>). Additionally, it allows you to bind two or more operations together using <a href="https://developer.apple.com/documentation/foundation/nsoperation/1412859-adddependency"><strong>dependencies</strong></a>. Lastly, the Operation class has <strong>many properties that can be observed using KVO</strong>, which allows developers to monitor its state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*ycjab19qycoFmTnw.png" /><figcaption>The OprationQueue class, same as DispatchQueue in GCD, controls one or many ops.</figcaption></figure><h3>Conclusion</h3><p>To conclude, choosing the right API to use comes down to the task you have at hand. Make sure to analyze and consider the tradeoffs between the two before choosing. I hope you found this article helpful in some way. If you did, don’t forget to leave some claps👏🏾 and feel free to comment if you have any question🚀</p><blockquote>About the Author :</blockquote><blockquote>Medi is a Software Engineer specialized in Mobile iOS development. He enjoys writing about Swift, iOS, Productivity, and Tech in general .You can get in touch with him through his <a href="http://mediassumani49@gmail.com/">email</a>, <a href="https://www.linkedin.com/in/medi-assumani/">LinkedIn</a> or <a href="https://www.makeschool.com/portfolio/mediassumani">Portfolio</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9de206afa620" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Tree Traversal in CS]]></title>
            <link>https://medium.com/@mediassumani49/understanding-tree-traversal-in-cs-76f8bf1a1c91?source=rss-d5fe5a88b33a------2</link>
            <guid isPermaLink="false">https://medium.com/p/76f8bf1a1c91</guid>
            <category><![CDATA[binary-search-tree]]></category>
            <category><![CDATA[trees]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Medi Assumani]]></dc:creator>
            <pubDate>Fri, 17 May 2019 22:48:40 GMT</pubDate>
            <atom:updated>2019-05-17T22:48:40.683Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn about depth and breadth first search for tree traversal</h4><h3>Overview</h3><p>Binary Search Tree is a type of tree that follows the following rules : Every children node on the left subtree are <strong><em>less than than parent node</em></strong> and every children node on the right subtree are <strong><em>greater than the parent node</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*bQaM3j0YEQSLfxXX08Y3bg.png" /><figcaption>A representation of a Binary Search Tree</figcaption></figure><p>As you can see, every purple-colored node is less than its parent and grand parents. For example, node (3) is less than its parent (6) and its grand parent (10). The same applies with the green-colored nodes; the node (17) is greater than its parent (14) and its grand parent (10). This principle can be very confusing at first but here’s a trick:</p><blockquote>“ Small, left. Big, right”</blockquote><h3>Tree Traversal</h3><p>The word traverse, in computer science, means to walk through a collection of data. With Binary Search Trees, we have two choices when it comes to this. We can either <strong><em>go deep or go wide</em></strong>. Going deep refers to an algorithm known as <strong><em>Depth First Search </em></strong>and going wide refers to<strong><em> Breadth First Search</em></strong>. Lets a closer look at each type of traversal.</p><h4>Depth First Search</h4><p>Here is the thing to remember about DFS, you traverse the tree to deepest node until it no longer has a child(known has leaf). We can do this in three ways :</p><ul><li><strong><em>in-order traversal</em></strong></li><li><strong><em>pre-order traversal</em></strong></li><li><strong><em>post-order traversal</em></strong></li></ul><h4>In-Order Traversal</h4><p>The goal of in-order travel, as it name says, is to <strong><em>visit every node in order from smallest node to greatest node</em></strong>. Let’s take a look at an example :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*q1Gg_qAu8llBaK0U1X6A6g.png" /><figcaption>in-order traversal diagram</figcaption></figure><p>Let’s take a look at how its implementation looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cad274dab8259da298385a9639ca182c/href">https://medium.com/media/cad274dab8259da298385a9639ca182c/href</a></iframe><p>Let’s analyze our algorithm:</p><ul><li><strong>Step 1</strong> : check if the root(10) is None, return an empty array if so because the return value(result) is an array.</li><li><strong>Step 2</strong> : check if (10) has a left child. If so, we recursively call the function with the root now being(6). This runs until we reach (3)’s left child, which is none. This will return an empty array and pop out of the recursive stack.</li><li><strong>Step 3</strong> : This is where we actually add or append the current root’s value in our result array. <strong><em>Each node we visit becomes a root within that call stack</em></strong>.</li><li><strong>Step 4</strong> : After visiting the root, we then go to the right children of the root.</li><li><strong>Step 5</strong> : once we reach the right most leaf, in our case (17), we return the array that <strong><em>has aggregated all our nodes in order</em></strong>.</li></ul><h4>Pre-Order Traversal</h4><p>Pre-order is just slightly different to in-order. We still start by visiting the l<strong><em>eft node</em></strong>, but instead of going to the root, we go to the <strong><em>right node</em></strong>. Finally we visit the <strong><em>root node’s data</em></strong> last.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*CzAUb7T3RG-XTrhLyRltwA.png" /><figcaption>pre order traversal diagram</figcaption></figure><p>The code for a post-order needs a single change from in-order:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64d06420da1c64bab457d53085d6076c/href">https://medium.com/media/64d06420da1c64bab457d53085d6076c/href</a></iframe><p>As you can see, the only change is that we are visiting the right node’ data (line 10) right after going the left node.</p><h4>Post Order Traversal</h4><p>For post order, we start at the <strong><em>root node</em></strong>, go to the <strong><em>left node</em></strong>, then the <strong><em>right node</em></strong>. Let’s take a look.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*ky5yMfkBduoubemj8k3OpQ.png" /><figcaption>post order traversal diagram</figcaption></figure><p>Similarly to the pre-order algorithm, this one will also need a simple tweak on line 8 where we always visit the current root node’s data before the children.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7766750da1b73841754578c3341cb1c0/href">https://medium.com/media/7766750da1b73841754578c3341cb1c0/href</a></iframe><h4>Breadth First Search</h4><p>Breadth first search has a different approach. The goal is to traverse through the tree level by level and visit each node as we’re doing it. Let’s take a look :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*mJzYTRZhFvlNPTkHjzncWw.png" /><figcaption>In BFS, we grab data from each nodes by level.</figcaption></figure><p>Let’s see how we can implement a breadth first algorithm.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b34db2c312e1fba1283a9069f5416797/href">https://medium.com/media/b34db2c312e1fba1283a9069f5416797/href</a></iframe><p>Let’s take a closer look at each steps to see what we’re actually doing.</p><p><strong>Step 1</strong>: we create a queue in order to <strong><em>keep track of the nodes we have visited in the previous level </em></strong>since we’re not using recursion.</p><p><strong>Step 2</strong> : we enqueue the root node as our starting point.</p><p><strong>Step 3</strong> : We are looping until the queue is empty <strong><em>because it will only be so if we’ve visited all nodes</em></strong>.</p><p><strong>Step 4</strong> : we dequeue the first element that was pushed in to visit it.</p><p><strong>Step 5</strong> : we visit the dequeued node by printing it.</p><p><strong>Step 6</strong> : if the dequeued node has a left child, <strong><em>we enqueue so we can dequeue it and visit it on the next iteration.</em></strong></p><p><strong>Step 7</strong> : we do the same thing as step 6 but for the right child.</p><h3>Conclusion</h3><p>To summarize everything we’ve learned, there are two main types of tree traversal: depth first and breadth first search. You need to know when is the proper time to use each to solve a specific problem. Thank you for reading this far and if you found this article helpful in any way, don’t forget to leave some claps 👏🏾.</p><blockquote>About the Author :</blockquote><blockquote>Medi Assumani is currently a Computer Science student at <a href="https://www.makeschool.com/">Make School</a> and iOS Developer in San Francisco, CA. You can get in touch with him through his <a href="http://mediassumani49@gmail.com/">email</a>, <a href="https://www.linkedin.com/in/medi-assumani/">LinkedIn</a> or <a href="https://www.makeschool.com/portfolio/mediassumani">Portfolio</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76f8bf1a1c91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to Core Data, Part 1]]></title>
            <link>https://medium.com/better-programming/a-light-intro-to-core-data-part-un-e344f9d1528?source=rss-d5fe5a88b33a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e344f9d1528</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[core-data]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Medi Assumani]]></dc:creator>
            <pubDate>Thu, 16 May 2019 19:03:42 GMT</pubDate>
            <atom:updated>2021-04-30T17:50:20.715Z</atom:updated>
            <content:encoded><![CDATA[<h3>An Introduction to Core Data</h3><h4>Intro to the low-level theory of Apple’s Core Data Framework</h4><h3>Overview</h3><p>Certain iOS applications require a way to save data on a mobile device for offline use. For example, Apple lets you play your downloaded music on iTunes, and Amazon’s Audible allows you to listen to your e-books without internet access. Those features are enabled due to a client-side caching framework known as Core Data. In this two-part series, we will take a close look at the theoretical components that you need to understand when working with applications that don’t rely on a backend server.</p><h3>What is Core Data?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/0*pKj2v1dOFcJu5ICp.png" /></figure><blockquote>“Core Data is a framework that you use to manage the model layer objects in your application” — Apple</blockquote><p>Model layer objects? Framework? You may be asking these questions if you are new to iOS programming, or programming in general.</p><p>Let’s define those terms: “<strong><em>framework</em></strong>” — this is a group of pre-defined methods, classes, and modules we can use at a high level to work with Core Data, without worrying about building it entirely on our own. In iOS programming, Apple provides a framework. In object-oriented programming, “<strong><em>model layer objects”</em></strong> refers to components of the application that encapsulate data into <strong><em>models</em></strong>. For example, a user model that has a name, id, email, and password property.</p><p>Essentially, Core Data provides us with a collection of predefined modules that we can use to create, read, update, and delete objects in a persistence layer.</p><h3>SQLite and Core Data</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJ9yGBmJjj9ZaQdcqDMdbQ.png" /></figure><p>Bear in mind that Core Data is not in itself a database such as MongoDB or SQL. Instead, it uses the built-in database system, <a href="https://www.sqlite.org/index.html">SQLite</a>, that comes with each iOS device. Core Data is a framework to manage an object graph, whereas SQLite is the actual relational database. You can read more on this <a href="https://cocoacasts.com/what-is-the-difference-between-core-data-and-sqlite/">here</a>. Now let’s dive into the main components of the Core Data framework.</p><h3>The Entity</h3><p>An entity is a class represented in the object graph. It has a name, properties, and (optionally) relationships. Each entity created is an instance of the <a href="https://developer.apple.com/documentation/coredata/nsentitydescription">NSEntityDescription</a> class, which we will look at more closely in part 2. For example, look at the following class declaration:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea3dee416260037b1efb50c94d3aea59/href">https://medium.com/media/ea3dee416260037b1efb50c94d3aea59/href</a></iframe><p>We want to use core data to store every Restaurant and Owner object locally for offline use. To do this we have to create them in the object graph like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mY_wjKlm9-Ei_3EPdoLL4Q.png" /><figcaption>A representation of the Restaurant entity in the object graph.</figcaption></figure><p>That’s the bare minimum you need to know about entities in Core Data. In part two of this article, we will look at how to create a fully functional Core Data application. Now let’s see how we can manipulate those entities in code. We can, for example, show a table view full of items and stores.</p><h3>The Object Graph</h3><p>Xcode provides an interface for developers to view each entity and its relationships in a database-like view. This is called the object graph and can be seen when you click on the “xcdatamodeld” file. The object graph is useful for many things, including viewing and editing your entities, creating relationships among your entities, and many other functionalities that we will investigate in part 2 of this piece.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/0*VMk5IdZYWvBlR17q.png" /><figcaption>An Xcode representation of an object graph.</figcaption></figure><h3>The Core Data Stack</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*no4WS_j7FwTwDR1_" /></figure><p>Think of the Core Data Stack as a team of main players that run the game. There are 4 main components we must be aware of: <strong><em>persistent container, managed</em></strong> <strong><em>object model</em></strong>, <strong><em>managed</em></strong> <strong>object context</strong>, and <strong><em>store coordinator</em></strong>. Each component has a specific task and coordinates with others to support Core Data. Let’s take a look at each of them.</p><h4>The Persistent container</h4><p>The persistent container is the higher level abstraction class that encapsulates the most important components of the core data stack. Creating your core data stack with the persistent container makes it easy for you to interact with Core Data. This is the framework’s declaration of the persistent container :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k7OZqQgxCmXhlNtsCQxFvg.png" /><figcaption>The NSPersistentContainer interface from Apple.</figcaption></figure><p>We will look at each of these in detail but here are the general concepts :</p><ul><li>name: whatever you named your “.xcdatamodeld”.</li><li>viewContext: this allows us to save, delete, and fetch data.</li><li>managedObjectModel : represents our created entities in memory.</li><li>persistentStoreCoordinator : helps the context and store communicate.</li></ul><blockquote>“NSPersistentContainer simplifies the creation and management of the Core Data stack by handling the creation of the managed object model , persistent store coordinator, and the managed object context.” — Apple</blockquote><h4>The Managed Object Model</h4><p>Next, we have the managed object model(NSManagedObjectModel). This is a programmatic representation of the .xcdatamodeld file. This is because when you fetch data (after being created and saved) from the store, Core Data needs a way to represent it in code so you can display, update, or delete it.</p><blockquote>“A managed object model allows Core Data to map from records in a persistent store to managed objects that you use in your application.” — Apple</blockquote><p>The big picture here is that all the entities, along with their properties and relationships, are represented by the managed object model. You can read <a href="https://developer.apple.com/documentation/coredata/nsmanagedobjectmodel">here</a> for more information.</p><h4>The Managed Object Context</h4><p>There are different types of operations when dealing with data storage. We can create, read, update, save, and delete data. Here is where the managed object context comes in play. The business layer of your application interacts with the Core Data Stack through the object context, which in turn keeps a reference to the persistent store coordinator every time we need to make changes to the data in the store. We will look at how to perform CRUD operation using the object context in part 2 of this article.</p><h4>The Persistent Store Coordinator</h4><p>Last but not least is the persistent coordinator. This acts as the bridge between the core data stack and the store(database). When an object context makes a request to fetch all the items in the database, the persistent coordinator is the one that loads them up from the SQLite store and passes them back to the object context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dOqMzugP-vGeXqMU44-fIg.png" /><figcaption>The persistent store coordinator is the link between the core data stack and the store(SQLite).</figcaption></figure><h3>Conclusion</h3><p>We have already learned a lot about the core data framework. This will help us tremendously when we create a core data application in part 2 since we will already know what each class and component does. Core Data is the most complex framework that iOS Engineers have to understand and work with it. Be patient, soon you will be connecting the dots!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e344f9d1528" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/a-light-intro-to-core-data-part-un-e344f9d1528">An Introduction to Core Data, Part 1</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refactoring a monolithic Application]]></title>
            <link>https://medium.com/@mediassumani49/refactoring-a-monolithic-application-aff08bb8f2a9?source=rss-d5fe5a88b33a------2</link>
            <guid isPermaLink="false">https://medium.com/p/aff08bb8f2a9</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[refactoring]]></category>
            <dc:creator><![CDATA[Medi Assumani]]></dc:creator>
            <pubDate>Fri, 03 May 2019 00:57:17 GMT</pubDate>
            <atom:updated>2019-05-17T15:17:55.356Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn quick tips of software refactoring to avoid technical debts.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rCUbfBg-CnW3PhCkZ-6R6Q.jpeg" /><figcaption>Image from <a href="https://unsplash.com/@cgower">Christopher Gower</a> on Unsplash.</figcaption></figure><h3>Overview</h3><p>As software engineers; or beginner programmers, we are constantly writing new code that enhance or introduce a new feature in the application. This can be a side project or an enterprise-level software. As the application grows and new engineers are introduced to the team, the codebase can get very messy and hard to maintain, hence causing technical debts that can lead to hundred of engineering hours lost and thousands of corporate dollars wasted. In this blog post, <strong>I will focus on four key refactoring techniques: maintainability, readability &amp; understandability, simplicity, and testability.</strong></p><h3>What is refactoring</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*qrIz_Hx8f2rwK6cWUQ5Eiw.png" /></figure><p>In Software Engineering, refactoring is the process of r<strong>e-writing some parts of an application in order to improve its current state.</strong> This is usually caused by mistakes or failure to adhere to certain guide lines and conventions due to a deadline. Let’s now dive deep on four factors i focused on when i refactored my application, <a href="https://github.com/MediBoss/GitviwrClient">Gitviwr</a>.</p><h3>Maintainability</h3><p><a href="https://github.com/MediBoss/GitviwrClient">Gitviwr</a> is a rather complex application that works by linking and communicating with multiple services : the chrome extension, the socket server, and the Github SDK. In order to have another engineer work on it, it must be kept up to date.</p><p>For example, I must make sure that all the dependencies are still compatible with the production environment, the codebase has a log of big changes, the release branch is in sync with the current production branch, and that it follows an <a href="https://www.manning.com/books/soa-patterns">SOA</a> pattern(the front and backend used to be on the same repository before refactoring).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2e_oFFBxzuVk-3jYkw_cEQ.png" /><figcaption>The client and server of Gitviwr are in two different repo. This is called called separation of concerns.</figcaption></figure><h3>Readability &amp; Understandability</h3><p>If a different developer were to look or work on Gitviwr, they must be able to read the codebase in a high level even if it’s written in an unfamiliar language or framework. I can put this into categories: Readability and Understandability.</p><p>The first one deals with the readability of the code. For example, <strong>having meaningful variable and functions names, good indentation, concise comments, and insightful documentation.</strong> To illustrate, we can look at the updateViewerCount() method below.</p><p>The function-level documentation gives you an idea of what the function does, the data types of each parameter and what they do. A client, which can be another developer, can simply call this method without needing to understand how it’s implemented. This introduces a new computer science concept called <a href="https://study.com/academy/lesson/data-abstraction-definition-example.html">data abstraction</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/280d288082d71215bb9091c6d4730b87/href">https://medium.com/media/280d288082d71215bb9091c6d4730b87/href</a></iframe><blockquote>There are only two hard things in Computer Science: cache invalidation and naming things.</blockquote><blockquote>— Phil Karlton</blockquote><p>The second part deals with understanding the structure and architecture of your codebase. In Gitviwr, i grouped different modules into folders that entails what they do. For example, i have the user.js file inside my models folder because it is a model; and the mailer.js into my helpers folder because it is file containing my mailing helper function used throughout the application. <strong>This promotes clarity and will facilitate other engineers to easily navigate through the application</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*64NnTc83Ve-qz71pbsyzAQ.png" /><figcaption>On the left panel, files are grouped into separate folder to improve the structure.</figcaption></figure><h3>Simplicity</h3><p>One of the great things about software development is its <strong>open sourced community</strong>. Whether your project is written in Javascript, Swift, or C#; you can always find libraries and frameworks that will do or simplify the job for you. For example, if a service of your application deals with storing and manipulating sensitive data, you may opt to use a library such as KeychainSwift or JWT instead of developing your own.</p><p>One benefit for this is that it will save you a ton of time because those frameworks are already fully built, tested, and trusted by hundreds if not thousands of other developers. On the other hand, if you develop your own, you may not be able to catch and address all different edge cases and security concerns. Let’s take a look how I replaced my own authentication service with <a href="http://www.passportjs.org/">Passport</a>’ Github strategy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8D-aKlkAJhyf-lzO8ykugw.png" /><figcaption>This small block of code replaced my 45 lines authentication route😁.</figcaption></figure><h3>Testability</h3><p>When you have an application containing tightly coupled modules and functions, it gets very hard to run <a href="https://www.guru99.com/component-testing.html">component testing</a>. Let’s see an example.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c77c11cc987b4c8446facafcf61fc87b/href">https://medium.com/media/c77c11cc987b4c8446facafcf61fc87b/href</a></iframe><p>Function queryUser will break the component test because it is tightly coupled with 3 other functions. Meaning, in order to successfully test this function, we must also test updateViewerCount, emailUser and updateCountOnClient . In order to fix this, we must make sure that each function does exactly one thing and return a value if applicable. The code snippet below shows how improved the queryUser() function to be testable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52577e4253daf80a70c5802dbdbdc3e7/href">https://medium.com/media/52577e4253daf80a70c5802dbdbdc3e7/href</a></iframe><h3>Conclusion</h3><p>Refactoring a huge, monolithic, and messy project can be daunting and sometimes risky. In order to avoid that, you must make sure to refactor chunk by chunk during development in order to avoid future technical debts that can hurt you in the future. If you found this article helpful or insightful in some way, don’t forget to leave some claps👏🏾</p><blockquote>About the Author :</blockquote><blockquote>Medi Assumani is currently a Computer Science student at <a href="https://www.makeschool.com/">Make School</a> and iOS Developer in San Francisco, CA. You can get in touch with him through his <a href="http://mediassumani49@gmail.com/">email</a>, <a href="https://www.linkedin.com/in/medi-assumani/">LinkedIn</a> or <a href="https://www.makeschool.com/portfolio/mediassumani">Portfolio</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aff08bb8f2a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>