<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tom Pearson</title>
    <description>The latest articles on DEV Community by Tom Pearson (@tom0pearson).</description>
    <link>https://dev.to/tom0pearson</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F167115%2F088762c3-1fe9-4688-ad88-c3a583591b9c.jpg</url>
      <title>DEV Community: Tom Pearson</title>
      <link>https://dev.to/tom0pearson</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tom0pearson"/>
    <language>en</language>
    <item>
      <title>MVVM and Coordinators is the Industry Standard Architecture</title>
      <dc:creator>Tom Pearson</dc:creator>
      <pubDate>Thu, 08 Aug 2019 09:23:05 +0000</pubDate>
      <link>https://dev.to/tom0pearson/mvvm-and-coordinators-is-the-industry-standard-architecture-2mo3</link>
      <guid>https://dev.to/tom0pearson/mvvm-and-coordinators-is-the-industry-standard-architecture-2mo3</guid>
      <description>&lt;p&gt;I had a lot of phone calls as interview first stages when I was recently applying for iOS Developer jobs. At some point we would always start talking about what architectural patterns I use or am comfortable with. Each time I would say that I used MVVM with Coordinators and more often than not it seemed to be like magic words were spouting from my mouth - I was normally greeted with "oh, we use that too" and definitely got me an upper hand. This was in London but I wouldn't be surprised if this translates to most other countries/tech hubs as well. &lt;/p&gt;

&lt;p&gt;So it seems that companies have widely adopted it rather than MVC/MVP/VIPER or anything else. My thoughts on why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Closely related to MVC so easy for the whole team and newcomers to adopt&lt;/li&gt;
&lt;li&gt;Allows reactive programming (RxSwift/Combine) to be easily slotted in as there are designated places for where the bindings should occur, and it seems like reactive programming will be the future&lt;/li&gt;
&lt;li&gt;Provides guidelines for where to place certain pieces of code which better helps organise things than MVC but is more flexible and pragmatic than VIPER&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What a coordinator looks like
&lt;/h3&gt;

&lt;p&gt;I'm only going to describe coordinators because I think view models are covered widely &lt;a href="https://www.swiftbysundell.com/posts/different-flavors-of-view-models-in-swift"&gt;elsewhere&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;There isn't a set rule for what is or isn't a coordinator. I arrived at something like the following that suited most of my needs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;protocol Coordinator {
    var parentViewController: UIViewController { get }
    func start()
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It's fairly simple but encapsulates everything a coordinator needs, something to present the new view controller that will be created, and a function to kick everything off. &lt;/p&gt;

&lt;p&gt;Then we would create a new coordinator for each distinct workflow. For example, a logging in coordinator would look something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class LoginCoordinator: Coordinator {
    let parentViewController: UIViewController

    init(parentViewController: UIViewController) {
        self.parentViewController = parentViewController
    }

    func start() {
        let loginViewController = LoginViewController()
        parentViewController.present(loginViewController, animated: true)
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is a simple example. Coordinators can be taken further if you want to restrict them to only be presented by other coordinators, so that they don't know about what ViewController is the root of which coordinator. In this case you would make a 'main' coordinator, and the coordinator protocol would have an array of  child coordinators so they hold reference to the coordinators that they are presenting. &lt;/p&gt;

&lt;p&gt;As the requirements of the workflow get more complex it's easy for the coordinator to get bloated. Also this example didn't use a view model but if we had used one the coordinator would be responsible for instantiating it and passing it into the view controller, so I'm sure you can appreciate things can get out of hand quickly. &lt;/p&gt;

&lt;h3&gt;
  
  
  Other skills in demand
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;TDD, but also just testing in general&lt;/li&gt;
&lt;li&gt;Reactive programming - RxSwift/Combine&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Further Reading
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.swiftbysundell.com/posts/different-flavors-of-view-models-in-swift"&gt;View Models&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.objc.io/books/app-architecture/"&gt;https://www.objc.io/books/app-architecture/&lt;/a&gt; - a good book about different architectural patterns, MVVM + Coordinators is one of the ones covered&lt;/p&gt;

</description>
      <category>ios</category>
      <category>swift</category>
      <category>architecture</category>
      <category>mvvm</category>
    </item>
    <item>
      <title>Namespaces in Swift</title>
      <dc:creator>Tom Pearson</dc:creator>
      <pubDate>Tue, 06 Aug 2019 14:58:33 +0000</pubDate>
      <link>https://dev.to/tom0pearson/namespaces-in-swift-2928</link>
      <guid>https://dev.to/tom0pearson/namespaces-in-swift-2928</guid>
      <description>&lt;p&gt;Namespaces in their simplest form are a way to group related areas of code. They make one of the hardest problems in programming, naming things, easier. They exist in a lot of other languages but not natively in Swift.&lt;/p&gt;

&lt;p&gt;Microsoft's C++ documentation says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Namespaces are used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;If you're working on a large codebase then you probably name classes specifically enough so you won't get them confused with other areas of the codebase. Unfortunately to achieve this we have to make the trade off of longer class names to get this specificity.  Also as we add more and more classes the global namespace gets more polluted, meaning that you end up with an information overload when trying to use autocomplete. &lt;/p&gt;

&lt;p&gt;For example you'd probably make classes like &lt;code&gt;LoginViewController&lt;/code&gt; or &lt;code&gt;ContactsDataSource&lt;/code&gt;. This can be taken to more of an extreme as you get into very specific workflows in a large codebase. &lt;/p&gt;

&lt;h3&gt;
  
  
   The Solution
&lt;/h3&gt;

&lt;p&gt;A nice, swifty way to solve this is to use an empty &lt;code&gt;enum&lt;/code&gt; to create a gateway into the specific workflow and implement all specific classes inside extensions on that enum. You can then access these classes using the dot syntax. So instead of the examples above you would have &lt;code&gt;Login.ViewController&lt;/code&gt; and &lt;code&gt;Contacts.DataSource&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;This also helps you organise code into logical groups - you know all the code related to the login flow will be under the &lt;code&gt;Login&lt;/code&gt; namespace. &lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation in Code
&lt;/h3&gt;

&lt;p&gt;Making the namespace is just making an empty enum:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;enum Login {}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then the classes are implemented as extensions to that enum in a new file, in this case probably called &lt;code&gt;Login+ViewController.swift&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;extension Login {
    class ViewController: UIViewController { ... }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We use an enum instead of a struct because you can't instantiate an empty enum, so it can purely be used for accessing other classes without confusion of what its purpose is.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/cpp/cpp/namespaces-cpp?view=vs-2019"&gt;Microsoft Namespace Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some speaker at a Meetup who said that he did this&lt;/p&gt;

</description>
      <category>swift</category>
      <category>ios</category>
    </item>
    <item>
      <title>What is Agile?</title>
      <dc:creator>Tom Pearson</dc:creator>
      <pubDate>Thu, 16 May 2019 21:53:24 +0000</pubDate>
      <link>https://dev.to/tom0pearson/what-is-agile-62f</link>
      <guid>https://dev.to/tom0pearson/what-is-agile-62f</guid>
      <description>&lt;p&gt;When I first started software development I had no idea what Agile was. Two years in I still had no idea what it was but I kept on hearing the word pop up in talks and the importance of it was always emphasised in job descriptions. Indeed, I practiced it at my company, according to the description on our website, but no one had ever explained how what I was doing was Agile. So I decided to do some research and figure out what everyone was talking about. &lt;/p&gt;

&lt;p&gt;The history of Agile can be directly traced back to 2001 when some software developers got together and proposed a new way of working on software projects. The problem was that initial commercial software projects were treated the same as a normal engineering project - a big plan made by 'smart' people was designed and then the 'dumb' workers would follow the plan (obviously this is a horrible way to look at it). An example of this is an architect designing a blueprint for a building and then labourers following the plan to build it. This project management practice is known as Waterfall. &lt;/p&gt;

&lt;p&gt;Software didn't adapt well to this. Software projects, and their requirements, tend to change shape a lot more than buildings - and so our agile founding fathers drew up some principles for more suitable practices based around flexibility, feedback and adapting to changing requirements. These are enshrined in the &lt;a href="http://agilemanifesto.org/"&gt;Manifesto for Agile Software Development&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rather annoyingly for us software engineers a lot of these principles were left intentionally vague. Perhaps so they would stand the test of time or to have them apply to as broad a range of situations as possible. &lt;/p&gt;

&lt;h2&gt;
  
  
  The principles
&lt;/h2&gt;

&lt;p&gt;A large part of the &lt;a href="http://agilemanifesto.org/principles.html"&gt;Agile manifesto's principles&lt;/a&gt; champion direct feedback between business people and developers. It prioritises the individuals and teams over organisations. And places working software with technical excellence as one of its goals. &lt;/p&gt;

&lt;p&gt;So basically an Agile project is the antithesis of a bureaucratic, cumbersome project run by a committee of managers who don't listen to any feedback from customers or workers. This helps us know what agile &lt;em&gt;isn't&lt;/em&gt; but still doesn't help us know what it is. Feedback is good but how much is too much before you get bogged down in meetings? Should you have standups? How many people before it gets too big? Should managers always consult with their teams before making any decisions? How do you actually decide what working software is? Should it matter what you think at all if the only purpose of the project is to satisfy the customer?&lt;/p&gt;

&lt;p&gt;We still don't really have a good answer to the question of what Agile is, mainly because there isn't a good answer. Agile varies company to company, team to team. It is just some guidelines of how development can happen. &lt;/p&gt;

&lt;p&gt;The reason Agile is so confusing is because it has been hijacked by people who have realised that they can sell the concept of Agile to companies who are looking to improve their development practices, even build careers (SCRUM Master) around it. This is a very cynical way to look at it but it also makes a lot of sense in explaining how it's used now compared to how it was intended to be used. &lt;/p&gt;

&lt;p&gt;Perhaps there is so much confusion around Agile because people are constantly trying to change it in order to sell it to you - Are you doing Agile? That's not Agile. Let me show you how to do it in my new book. &lt;/p&gt;

&lt;p&gt;Or maybe it's because we want to be told exactly what Agile is, and to have the gap left by the  writers of the manifesto filled in. Maybe we don't want to have to struggle with the questions that it presents but  would rather have someone rigorously define it for us so we don't have to think, and the problem is we can't decide who's interpretation is the most valid or we get bored of one and jump to another.&lt;/p&gt;

&lt;p&gt;As Dave Thomas, one of the founding fathers, says we shouldn't really use the word Agile as we do. It's been turned into a noun. It was intended to be used as the verb - as in practices that are agile. As he points out, it's interesting that we now use it with a capital A, the same way we refer to God. &lt;/p&gt;

&lt;h2&gt;
  
  
  The sad reality
&lt;/h2&gt;

&lt;p&gt;So sadly Agile has lost its intrinsic meaning over time and has become not much more than a buzzword slapped on job descriptions and websites. My advice is not to try to understand it because you'll never be able to keep up with it, or convince others of what it truly is (or more importantly isn't) because they have already formed and latched onto their own idea of it. Put that you practice it on your resume and forget about it. &lt;/p&gt;

</description>
      <category>agile</category>
      <category>productivity</category>
      <category>management</category>
      <category>career</category>
    </item>
  </channel>
</rss>
