<?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 Nebil Kriedi on Medium]]></title>
        <description><![CDATA[Stories by Nebil Kriedi on Medium]]></description>
        <link>https://medium.com/@nebillo?source=rss-946071563fce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HQSKnqKU0UA-qDVSQCV6ow.jpeg</url>
            <title>Stories by Nebil Kriedi on Medium</title>
            <link>https://medium.com/@nebillo?source=rss-946071563fce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:48:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nebillo/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[Scaling-up an iOS app with modularisation]]></title>
            <link>https://engineering.depop.com/scaling-up-an-ios-app-with-modularisation-8cd280d6b2b8?source=rss-946071563fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cd280d6b2b8</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[modularization]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[build-time]]></category>
            <category><![CDATA[architecture]]></category>
            <dc:creator><![CDATA[Nebil Kriedi]]></dc:creator>
            <pubDate>Tue, 07 May 2019 14:43:58 GMT</pubDate>
            <atom:updated>2019-05-09T15:11:29.818Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scaling up an iOS app using modules</h3><h3>Introduction</h3><p>With this blog post we want to share the challenges we have faced over the past couple of years while scaling up the development of the Depop iOS application, both in terms of number of features developed in parallel, and in terms of number of contributors to the code base.</p><p>We will explain how in this context it is critical to <strong>modularise</strong> a large and old codebase, into small, independent and testable components. Along the way we will also share some of the solutions we adopted to deal with <strong>dependency management</strong> and to optimise <strong>build performance</strong> in a continuous delivery setup.</p><h3>Overview</h3><p>Here’s how the codebase of our app looked like in its initial shape.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_LiZXgt9yc8AHp1pQ39Kw.png" /><figcaption>Pods is the CocoaPods project containing the entire application dependencies.</figcaption></figure><p>At the time when we started, this was simple enough to build most of the features needed. However, as you can probably imagine, with this approach any new feature is added into the mix with hundreds of others and <strong>no clear separation between critical boundaries</strong> like for example UI, API, Data, etc.</p><p>As a result, the amount of bugs, crashes, and headaches increased, mostly due to unpredictable side effects caused by a growing team of engineers and an increasing demand for building new features.</p><p>If you have ever worked in a fast-growing company, this definitely sounds familiar!</p><h3>Initial approach</h3><p>With things getting worse over time, we decided to focus on creating <strong>clear boundaries</strong> between the main macro-components of the code base. And so we decided to adopt a traditional <a href="https://en.wikipedia.org/wiki/Multitier_architecture"><strong>layered architecture</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H0b7-9ZJFtUxUnTi6fzLvQ.png" /><figcaption><em>Each of these boxes represent an Xcode Project added into our workspace, each of which contains a dynamic framework. The main application target would still be located inside the “old features” project and would embed all other frameworks.</em></figcaption></figure><ul><li>Blue layer: contains UI components for all new features (mostly view controllers) and styling logic, and these are used by all the features (including the old ones).</li><li>Green layer: contains non-UI logic such as DB and API clients. All upper layers have direct access to this.</li><li>Yellow layer: contains utility methods and functions, completely independent from the logic of all the other features, and thus shared across the entire codebase.</li></ul><p>We started seeing immediate benefits, particularly for all new features, which in fact resulted being way more stable and robust.</p><p>Unfortunately we later realised that this approach was only saving us some time, and in fact these layers started growing into big monoliths like the original one, as our increasingly <strong>slower build times</strong> were showing!</p><h3>Solution</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9WpkpWJs3-korJXVqddSjg.png" /></figure><ul><li>The big UI layer is now split into multiple modules, separated according to their domain.</li><li>Core Service and Core UI contain low level components which need to be shared by every module (e.g. API clients, fonts, colours, etc…)</li><li>The <a href="https://cocoapods.org/">CocoaPods</a> project is gone! Every module now links only the dependencies it requires as pre-built dynamic frameworks.</li></ul><p>This gave us much more stability whenever we were adding a new feature, and it also allowed us to experiment new design patterns safely.</p><p>We also reduced drastically the risk of creating conflicts when pull requests are merged, since each developer will most likely work within a single domain.</p><p>What about build time? The approach we followed is very simple: we only build what’s changed; we only run test for what’s needed. And this was possible thanks to <a href="https://github.com/Carthage/Carthage#adding-frameworks-to-an-application">Carthage</a>, which provides easy caching for third party artefacts.</p><p>The rest of the blog post shows what all of the above means in practice: our very first <strong>module, </strong>Chat. We also explain how we approached the migration to this new world at scale.</p><h3>What is a module?</h3><p>Here’s a definition of <a href="https://en.wikipedia.org/wiki/Modular_programming">Modular Programming</a> from Wikipedia:</p><blockquote><strong>Modular programming</strong> is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable <strong>modules</strong>, such that each contains everything necessary to execute only one aspect of the desired functionality.</blockquote><p>For us, a module contains code belonging to the same domain of functionalities. Here’s how it looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhNrKbUHNt5n0a1X_kSpKw.png" /><figcaption>The view of a module defined as a dynamic framework inside a dedicated Xcode Project.</figcaption></figure><p>The code and resources needed for each functionality is defined in this framework, including its unit tests.</p><p>Most of these implementation details will remain segregated within the boundaries of this module (or framework). Only the interfaces useful for the external consumers are exposed via the framework public interface.</p><p>This one plays an important role when a module needs to access another one. Let’s explain this.</p><h3>Accessing another module</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*be4IWJQnlKPsSj0uGQhXdw.png" /><figcaption>Module A cannot access directly Module B</figcaption></figure><p>We want every module to be completely independent. In this way if Module A is modified this will have no impact on any of its consumer. This also means we only need to re-compiled the modified module and not the whole project.</p><p>What about when you need to access another module?</p><p>Example: I’m in module A and I want to navigate to a screen defined in Module B. Here’s how the code would like like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1d4f8e4f407778d3d5d42c190dce2a3/href">https://medium.com/media/d1d4f8e4f407778d3d5d42c190dce2a3/href</a></iframe><p>In this way modules are loosely coupled: we don’t need to know the concrete type of the view controller we want to navigate to, nor we need to know how to configure it. We simply pass-in any input to the factory method to obtain a generic instance ready to be presented.</p><p>We’ll explain what that Dependencies class is, but first of all let’s define the module public interface.</p><h3>The module public interface</h3><p>Every module defines its public interface as a Swift protocol, describing what behaviours will be exposed outside. All these interfaces are defined into a common “Dependencies” layer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae91987bdf3df776486a3e62d1b014eb/href">https://medium.com/media/ae91987bdf3df776486a3e62d1b014eb/href</a></iframe><p>The module can expose both view controllers and plain objects used to perform any kind of background tasks. In either case the real type of these object is never revealed to the consumer.</p><p>Now let’s see a concrete implementation.</p><h3>Implementing the module</h3><p>Every module has to conform to its public interface. This is done via this class defined inside the module framework:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/409a4f6ae4c9b79421d08e72c1c1881b/href">https://medium.com/media/409a4f6ae4c9b79421d08e72c1c1881b/href</a></iframe><p>We now need a way to request an instance of this module and consume it. This is done by the Dependency Manager.</p><h3>The dependency manager</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9d5d739a67f7060adb1d1e23b887da8/href">https://medium.com/media/f9d5d739a67f7060adb1d1e23b887da8/href</a></iframe><p><em>Note: This class inherits from DependencyManager, which is a simple class used to register and resolve dependencies. If you want more details check-out our sample project at the end of the blog post.</em></p><p>We now have a way to request an instance of a module. We just need one last thing before we can consume it, tell the dependency manager how to resolve the dependency.</p><h3>Resolving the dependency</h3><p>The main app target is a great place to provide concrete implementation for these dependencies, as it “sits” above any module.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22a6220204d9bb5242576ec5ec5ec517/href">https://medium.com/media/22a6220204d9bb5242576ec5ec5ec517/href</a></iframe><p><em>Note this is the only place in the entire project where we import Chat module.</em></p><p>The main application target will be re-compiled every time there’s a change in any module. It should therefore be very light and quick to compile.</p><p>That’s it! Now we can consume our new module from anywhere in the app.</p><h3>Conclusion</h3><p>Here’s a quick overview of what we just did:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Webe8D4e50EyQx26N8vekw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V4yGM2RhYkyu8IhA-MYsgQ.png" /><figcaption>The project before (left) and after (right) the migration. <em>Utils has been omitted as there was no substantial change.</em></figcaption></figure><p>This process can become quite complex so you need to <strong>approach it incrementally</strong> one module at a time.</p><p>It’s important to have a rough idea of how much effort you need to invest before you start moving things around. A simple way to <strong>assess the effort</strong> is this:</p><ol><li>Identify the core files belonging to your domain.</li><li>Create a brand new Xcode project (outside of your workspace) and copy those files there.</li><li>Try to compile. This will reveal all your implicit dependencies.</li><li>Make a list of these dependencies and plan your migration accordingly.</li><li>Start from “lower” layers (core Service / core UI) before moving up, as this will help to reach intermediate milestone with valid green builds.</li></ol><p>Unfortunately there is lots of <strong>boilerplate</strong> involved in creating a new Xcode Project, adding this to your workspace and linking it with the correct frameworks. Remember repetition makes perfection. Be focused on your goal and you’ll find ways to optimise this later.</p><p>Make sure the whole team contributes, enable collaboration and promote feedback sharing. In our case we found that <strong>documenting the whole process</strong> was extremely valuable.</p><p>Build performance is still an issue we are working on. However, the work we have just described has enabled us to introduce <a href="https://github.com/Carthage/Carthage">Carthage</a> to manage third party dependencies and to cache dynamic frameworks. Going forward we want to apply this approach to our internal frameworks as well, so that we will only build and tests what is needed.</p><p>We look forward to sharing more updates with you soon and to hearing your feedback!</p><h3>Sample Project</h3><p>Download the sample project from our repo:</p><p><a href="https://github.com/depop/my-first-module">https://github.com/depop/my-first-module</a></p><h3>We’re hiring!</h3><p>You can check out our open roles <a href="https://www.depop.com/about/jobs">here</a> and follow our <a href="https://www.linkedin.com/company/2347595/">LinkedIn page</a>. If you have a background in machine learning but don’t see the perfect role for you, or just want to pop by our offices for a chat and a tour get in touch: <a href="/service/mailto:work@depop.com">work@depop.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cd280d6b2b8" width="1" height="1" alt=""><hr><p><a href="https://engineering.depop.com/scaling-up-an-ios-app-with-modularisation-8cd280d6b2b8">Scaling-up an iOS app with modularisation</a> was originally published in <a href="https://engineering.depop.com/">Engineering at Depop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reusable Behaviours in UIViewControllers]]></title>
            <link>https://engineering.depop.com/reusable-behaviours-in-uiviewcontrollers-d3d5cacdb395?source=rss-946071563fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3d5cacdb395</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[protocol-oriented]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[uikit]]></category>
            <dc:creator><![CDATA[Nebil Kriedi]]></dc:creator>
            <pubDate>Tue, 19 Sep 2017 15:59:34 GMT</pubDate>
            <atom:updated>2017-09-20T12:02:02.968Z</atom:updated>
            <content:encoded><![CDATA[<p>This post demonstrates an approach for writing reusable Swift code when working with UIViewControllers in an iOS app.</p><h3>Introduction</h3><p>My name is Nebil and I am an iOS engineer at Depop. My team develops and maintains our iOS application. Here’s how it looks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*evhQEABBxVckpWY_RSo9NA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*vLZ3oQFslwEje2jwcZn8cw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*h-M0IAXy1e1VdrWTfIbYEQ.png" /></figure><p>Pretty much every screen in the app consumes data downloaded from a RESTful API, and as a result several behaviours are common and must be implemented in multiple view controllers.</p><p>What typically happens whenever a screen is presented is the following:</p><ul><li>A loading indicator is shown when the first set of data is downloaded</li><li>If something goes wrong an alert is displayed</li><li>If no data is available we show an empty state</li><li>In case of lists, we automatically load the next page as the user scrolls to the bottom</li></ul><p>If this sounds familiar then you might have come across the same challenges we have faced.</p><h3>Challenges</h3><ol><li>UI/UX Consistency: a given behaviour should always look and work the same way across the whole app.</li><li>Code reusability: each behaviour should be implemented in a single place in the codebase.</li><li>Flexibility: we want to be able to easily adopt any of these behaviours from any view controller.</li><li>Customisation: we want to be able to easily extend the default implementation of any of these behaviours.</li></ol><h3>The Initial Solution</h3><p>At the beginning we used <strong>inheritance </strong>with a base UIViewController implementing all behaviours.</p><p>We used this approach for quite some time, until we realised that things were getting too complex — the code was hard to maintain and to reason about.</p><p>Furthermore the base class was tightly coupled with the UITableView class, making it hard to extend to support other components such as UICollectionView.</p><p>We soon realised that <strong>composition</strong> was a design pattern better suited for our needs.</p><h3>The Final Solution</h3><p>Things became a lot easier once Apple introduced <a href="https://developer.apple.com/videos/play/wwdc2015/408/">Protocol Oriented Programming</a> (aka POP) using Swift.</p><p><strong>Introducing “Presentable”</strong></p><p>In protocol oriented programming you use a protocol to describe a particular behaviour. Here’s how we ended up defining the API required to present a loading indicator:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/669bd08cd92a02502a426e7e04f31d70/href">https://medium.com/media/669bd08cd92a02502a426e7e04f31d70/href</a></iframe><p><strong>Provide a Default Implementation</strong></p><p>Thanks to Swift’s protocol extension it is possible to provide a default implementation for our new method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8c93b23e31ea551dd328df075abaacd/href">https://medium.com/media/c8c93b23e31ea551dd328df075abaacd/href</a></iframe><p><em>Swift documentation for “</em><a href="https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Generics.html#//apple_ref/doc/uid/TP40014097-CH26-ID553"><em>generic where clause</em></a><em>”.</em></p><p><strong>Adopting “Presentable”</strong></p><p>Now any UIViewController can adopt the loading view behaviour described above simply by doing this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20e143fd0d80bb3e9c96249bd8d29a6f/href">https://medium.com/media/20e143fd0d80bb3e9c96249bd8d29a6f/href</a></iframe><p>All we have to do in order to show or hide the loading view is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28bfda0146f6d8a919dc1773435f6102/href">https://medium.com/media/28bfda0146f6d8a919dc1773435f6102/href</a></iframe><p><em>Note that in order to adopt this behaviour a consumer does not need to know the concrete type of the view controller, something really powerful when it comes to unit testing.</em></p><p>Working with protocols is a great advantage in architectures like <a href="http://digital.travelport.com/blog/architecting-mobile-apps-with-bviper-modules">VIPER</a> where a screen is composed of smaller independent components loosely coupled and thus very easy to test.</p><p><strong>Customising The Default Implementation</strong></p><p>Whenever we need to go beyond the default behaviour we can simply override the method of the protocol and implement our custom logic.</p><p>In the following example we have a view controller with a custom refresh control which should stop refreshing once the loading spinner is dismissed:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c2c0f1655231681c4b8ad0b026745cf/href">https://medium.com/media/7c2c0f1655231681c4b8ad0b026745cf/href</a></iframe><p><em>Note that by calling defaultLoadingViewStatus(…) we can still invoke the original implementation defined in the protocol extension.</em></p><p><strong>Combining Behaviours</strong></p><p>We can combine multiple protocols together to describe a more complex behaviour that can be reused by several screens throughout the app.</p><p>For example, here’s how a view controller which loads a paginated list might look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61d0218d7adb45c10c9c258d93f19354/href">https://medium.com/media/61d0218d7adb45c10c9c258d93f19354/href</a></iframe><h3>Conclusion</h3><p>We have been using this approach for more then a year now and we are very happy with the results.</p><p>We are now using this approach throughout the app and especially updating all our legacy code to this pattern.</p><p>We are very excited about the capabilities of Swift and Protocol Oriented Programming and we look forward to seeing how these features can help us solve more problems in the future.</p><h3>We’re hiring!</h3><p>You can check out our open roles <a href="https://www.depop.com/about/jobs">here</a> and follow our <a href="https://www.linkedin.com/company/2347595/">LinkedIn page</a>. If you have a background in engineering but don’t see the perfect role for you, or just want to pop by our offices for a chat and a tour get in touch: work@depop.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3d5cacdb395" width="1" height="1" alt=""><hr><p><a href="https://engineering.depop.com/reusable-behaviours-in-uiviewcontrollers-d3d5cacdb395">Reusable Behaviours in UIViewControllers</a> was originally published in <a href="https://engineering.depop.com/">Engineering at Depop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>