# The Coded Self

A software developer that strives to write clean software that enables businesses to solve problems. Keegan specializes in all things Apple, especially iOS. He loves experimenting with different tech and different ways of thinking.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Perfect is the Enemy of the Good

DevFeed: [Perfect is the Enemy of the Good](<https://devfeed.tech/articles/perfect-is-the-enemy-of-the-good-22305.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/Perfect-Is-The-Enemy-Of-The-Good/>)

Author: Keegan Rush

Published: 2018-11-13T00:00:00Z

Content type: opinion

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Development](<https://devfeed.tech/topics/development.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [reactive](<https://devfeed.tech/topics/reactive.md>), [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [Mocking](<https://devfeed.tech/topics/mocking.md>), [App](<https://devfeed.tech/topics/app.md>)

Tags: [architecture](<https://devfeed.tech/tags/architecture.md>), [architecture-pattern](<https://devfeed.tech/tags/architecture-pattern.md>), [async](<https://devfeed.tech/tags/async.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [development](<https://devfeed.tech/tags/development.md>), [dispatchqueue](<https://devfeed.tech/tags/dispatchqueue.md>), [mocking](<https://devfeed.tech/tags/mocking.md>), [programming](<https://devfeed.tech/tags/programming.md>), [queue](<https://devfeed.tech/tags/queue.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [reactive-programming](<https://devfeed.tech/tags/reactive-programming.md>)

### AI overview

The author reflects on a side project whose elaborate architecture and extensive tooling created hidden complexity, debugging difficulties, and development friction. The article examines the use of RxSwift, VIPER, Swinject, Cuckoo, and Flow Operations in an app and argues that architectural perfection can undermine practical progress.

### Source excerpt

How the Wrong Architecture Can Cripple Development A couple of years ago, I was working on a side project with a few friends. We thought that it would be the next big thing. We put our collective best efforts into it; I worked long, hard hours fleshing out the scaffolding of the perfect architecture. Little did I know that my effort would doom the project to join the abyss of failed projects as quickly as it had begun. We had the best tools Since this was The Next Big Thing™, we used everything at our disposal. RxSwift for reactive programming VIPER for our architecture pattern Swinject for dependency injection Cuckoo for mocking Flow Operations for managing navigation The Flow Operations were a particularly interesting concept, inspired by the Advanced NSOperations session from WWDC 2015. We used Flow Operations to manage navigation in the app. For instance, if you wanted to register a new user, you'd invoke a RegisterFlowOperation. A FlowOperation was a subclass of Operation: class FlowOperation: Operation The Operation class represents the code and data for a task of your choosing. It also handles concurrency and dependencies. So, our Flow Operations represented the task of flowing from one screen to another in an app. Operations can be dependent on each other - for instance, the EditProfileFlowOperation is dependent on the SignInFlowOperation. If you've already signed in, you can edit your profile, but if you haven't, then you'll be directed to sign in if you invoke the EditProfileFlowOperation. How does it work? There was a lot of hidden complexity in the Flow Operation system, and some trickiness that you wouldn't notice until you started using it. I'll briefly go over some of the code. You could sell products in this app we were building. This is how you'd start the Sell Flow: private func startSellFlow() { DispatchQueue.global().async { [navController = navController] in let flow = SellFlowOperation(navigationController: navController) flow.beginFlow() flow.

## UI Testing the Clean Way

DevFeed: [UI Testing the Clean Way](<https://devfeed.tech/articles/ui-testing-the-clean-way-22309.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/UI-Testing-The-Clean-Way/>)

Author: Keegan Rush

Published: 2018-10-23T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Testing](<https://devfeed.tech/topics/testing.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [Xcode](<https://devfeed.tech/topics/xcode.md>), [To-Do](<https://devfeed.tech/topics/todo.md>)

Tags: [bugs](<https://devfeed.tech/tags/bugs.md>), [reuse](<https://devfeed.tech/tags/reuse.md>), [swift](<https://devfeed.tech/tags/swift.md>), [testing](<https://devfeed.tech/tags/testing.md>), [ui-testing](<https://devfeed.tech/tags/ui-testing.md>), [xcode](<https://devfeed.tech/tags/xcode.md>)

### AI overview

This tutorial discusses keeping Swift UI tests clean and readable using a To-Do list app. It explains that Xcode's recorded UI tests can produce unreadable, brittle, duplicated code and may fail to capture some interactions, then introduces a cleaner testing approach.

### Source excerpt

I write software, and sometimes I write bugs. But, when I do, I catch them early with testing. I do manual tests before I commit, I write unit tests as I write my code. Lately, I've also been getting into writing UI tests. One critique of UI testing is how messy and brittle it can be. Building the tests can be complicated. You might spend hours on a test just for a design to change that breaks the test and ruins all your hard work. So, I want to tell you about some problems you might face in keeping your UI tests clean and readable, and how we can leverage Swift for this endeavour. I'll walk you through my approach to UI testing with everyone's favorite example project - a To-Do list app. I know, boring, right? Well, it works perfectly for the examples we'll be looking at, so... You can download the example project here. It's a simple app that allows us to create, edit, and delete a to-do. Just press record UI testing in Xcode is easy. Click inside the body of an empty UI test, click the Record button, and you're up and running. Let's start off by recording a UI test to add a new to-do. That was easy! And it sure did create a lot of code. That must be good, right? func testExample() { let app = XCUIApplication() app.navigationBars["Todo List"].buttons["Add"].tap() let textField = app.otherElements.containing(.navigationBar, identifier:"New Todo") .children(matching: .other).element.children(matching: .other).element .children(matching: .other).element.children(matching: .textField).element textField.tap() textField.tap() let datePickersQuery = app.datePickers datePickersQuery.pickerWheels["October"]/*@START_MENU_TOKEN@*/.press(forDuration: 0.6);/*[[".tap()",".press(forDuration: 0.6);"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ datePickersQuery.pickerWheels["9"]/*@START_MENU_TOKEN@*/.press(forDuration: 0.5);/*[[".tap()",".press(forDuration: 0.5);"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ app.buttons["Done"].tap() } I'll be honest, most of that is unreadable to me. Run

## Creating a macOS Action (Gear) Button Programmatically in Swift

DevFeed: [Creating a macOS Action (Gear) Button Programmatically in Swift](<https://devfeed.tech/articles/creating-a-macos-action-gear-button-programmatically-in-swift-22317.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/macOS-action-button-swift/>)

Author: Keegan Rush

Published: 2018-07-17T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [macOS](<https://devfeed.tech/topics/macos.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [Code](<https://devfeed.tech/topics/code.md>), [ui](<https://devfeed.tech/topics/ui.md>)

Tags: [app](<https://devfeed.tech/tags/app.md>), [code](<https://devfeed.tech/tags/code.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [macos](<https://devfeed.tech/tags/macos.md>), [swift](<https://devfeed.tech/tags/swift.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

A tutorial on creating a macOS action button programmatically in Swift. It explains how to use an NSPopupButton, position it, add menu items, add the system gear icon, and configure its button cell styling.

### Source excerpt

For a list of actions on macOS, the standard control is an action button as defined in the macOS Human Interface Guidelines. Here's the definition from that page: An action button (often referred to as an action menu) is a specific type of pull-down button that operates like a contextual menu, without the disadvantage of being hidden, providing access to app-wide or table-specific commands. An action button includes a gear icon when closed and a downward arrow indicator that alludes to its menu. Action buttons are often used in toolbars, but can also be used in the content area of a view beneath a table view. Apple isn't very clear about how to create one of these in code. They tell you to create a button using the system-provided gear icon by making use of the NSImageNameActionTemplate image name, but try as I might, I couldn't replicate the action button used in Finder from that image name alone. It turns out that there are a few more steps involved. Create an NSPopupButton let actionButton = NSPopUpButton(frame: .zero, pullsDown: true) It's clear that the button is an NSPopupButton due to the dropdown that it presents. Position the button view.addSubview(actionButton) actionButton.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ actionButton.centerXAnchor.constraint(equalTo: view.centerXAnchor), actionButton.centerYAnchor.constraint(equalTo: view.centerYAnchor) ]) Position the button where you need it. For the purposes of this demo, I'm leaving it right in the middle of the parent view. For the reasoning behind actionButton.translatesAutoresizingMaskIntoConstraints = false, take a look at my post on autoresizing masks. We've created the button and positioned it in the view. This is the result: It's coming together! Add some items ["Option 1", "Option 2", "Option 3"].forEach(actionButton.addItem) An action button isn't too useful without some actions. With an array of item titles, we use the forEach operator to add the items to the a

## Autoresizing Masks and You

DevFeed: [Autoresizing Masks and You](<https://devfeed.tech/articles/autoresizing-masks-and-you-22313.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/autoresizing-masks/>)

Author: Keegan Rush

Published: 2018-01-23T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [iOS](<https://devfeed.tech/topics/ios.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [console](<https://devfeed.tech/tags/console.md>), [container](<https://devfeed.tech/tags/container.md>), [interface](<https://devfeed.tech/tags/interface.md>), [layout](<https://devfeed.tech/tags/layout.md>), [property](<https://devfeed.tech/tags/property.md>), [spring](<https://devfeed.tech/tags/spring.md>)

### AI overview

This tutorial explains how autoresizing masks work in iOS and why they can conflict with Auto Layout constraints. It describes the springs-and-struts layout model, the mask values that control resizing and positioning, and how UIKit converts autoresizing behavior into automatic constraints.

### Source excerpt

You're an Autolayout Wizard. You know Interface Builder like the back of your hand. Then, one day, you create a simple UIView, add it as a subview with some elegantly crafted constraints, and.. it blows up in your face. What gives? Take a look at this code example that tries to create a UILabel and center it in the view. let centerLabel = UILabel() centerLabel.text = "Perfectly centered!" view.addSubview(centerLabel) NSLayoutConstraint.activate([ centerLabel.centerXAnchor.constraint( equalTo: view.centerXAnchor, constant: 0), centerLabel.centerYAnchor.constraint( equalTo: view.centerYAnchor, constant: 0) ]) Try this, and you'll be thoroughly disappointed. The perfectly centered label is nowhere to be found. Luckily, the console output provides a vital clue. [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSAutoresizingMaskLayoutConstraint:0x60400009cb60 h=--& v=--& UILabel:0x7f927f2021b0'Perfectly centered!'.midY == 0 (active)>", "<NSLayoutConstraint:0x608000099140 UILabel:0x7f927f2021b0'Perfectly centered!'.centerY == UIView:0x7f927f1017b0.centerY (active)>", "<NSLayoutConstraint:0x60400009cd90 'UIView-Encapsulated-Layout-Height' UIView:0x7f927f1017b0.height == 568 (active)>", "<NSAutoresizingMaskLayoutConstraint:0x60400009ce30 h=-&- v=-&- 'UIView-Encapsulated-Layout-Top' UIView:0x7f927f1017b0.minY == 0 (active, names: '|':UIWindow:0x7f927bd073a0 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x608000099140 UILabel:0x7f927f2021b0'Perfectly centered!'.centerY == UIView:0x7f927f1017b0.centerY (act

## Function Injection for Testable Swift Code

DevFeed: [Function Injection for Testable Swift Code](<https://devfeed.tech/articles/functions-deserve-injection-too-22315.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/functions-deserve-injection/>)

Author: Keegan Rush

Published: 2017-11-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Swift](<https://devfeed.tech/topics/swift.md>), [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [swift](<https://devfeed.tech/tags/swift.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>)

### AI overview

This tutorial presents function injection in Swift as a way to pass function dependencies into other functions. It explains how the technique can keep tests short and focused while avoiding repeated validation tests and unnecessary classes or dependency containers.

### Source excerpt

Lately, I've been taking advantage of Swift's functional abilities where it makes sense to help me write concise and clear code that's easy to test. I'd like to share one technique that has helped me to eliminate repetition and breakages of encapsulation in tests: function injection. In traditional dependency injection, an object that is dependended on is passed to the method that depends on it. Function injection is my name for following the same approach when your function consumes another function. As a code base evolves over time, a lot of small, focused utilities are added. Here's one small utility function that I use quite often: extension String { func isNonEmpty() -> Bool { return !trimmingCharacters(in: .whitespacesAndNewlines).isEmpty } } This eliminates the verbosity of checking if a string is empty or contains only whitespace. It is, understandably, quite easy to test as well. func testNoCharactersReturnsTrue() { XCTAssertFalse("".isNonEmpty()) } func testOnlyBlankSpacesReturnsTrue() { XCTAssertFalse(" ".isNonEmpty()) } func testNewlineReturnsTrue() { XCTAssertFalse(" \n ".isNonEmpty()) } func testNonEmptyStringReturnsFalse() { XCTAssertTrue("Hello there".isNonEmpty()) } As an example, imagine that we're using this in an app for a clothings store. When you walk into the store, you should get a push notification from the app with a greetings message containing the user's name. If there's something wrong with the user's name - if it's empty or whitespace - we'll throw an error. struct Greeter { func greet(name: String) throws -> String { guard name.isNonEmpty() else { throw GreetingError.invalidName } return "Welcome, \(name)! Have you seen the specials on offer?" } } Let's write some tests for this function. We want to test two things: The returned message is correct when the name is valid An error is thrown when the business logic determines that a name is invalid func testGreetingWithValidNameReturnsGreetingString() { let expected = "Welcome, Caroline!

## Staying Sane with Cuckoo and Code Generation

DevFeed: [Staying Sane with Cuckoo and Code Generation](<https://devfeed.tech/articles/staying-sane-with-cuckoo-and-code-generation-22314.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/cuckoo-and-code-generation/>)

Author: Keegan Rush

Published: 2017-10-30T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Swift](<https://devfeed.tech/topics/swift.md>), [Mocking](<https://devfeed.tech/topics/mocking.md>), [Code generation](<https://devfeed.tech/topics/code-generation.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>), [Objective-C](<https://devfeed.tech/topics/objective-c.md>)

Tags: [c](<https://devfeed.tech/tags/c.md>), [code](<https://devfeed.tech/tags/code.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [consistency](<https://devfeed.tech/tags/consistency.md>), [library](<https://devfeed.tech/tags/library.md>), [mocking](<https://devfeed.tech/tags/mocking.md>), [swift](<https://devfeed.tech/tags/swift.md>), [tdd](<https://devfeed.tech/tags/tdd.md>), [tests](<https://devfeed.tech/tags/tests.md>), [unit-tests](<https://devfeed.tech/tags/unit-tests.md>)

### AI overview

The article introduces Cuckoo, a Swift mocking framework that uses code generation to create mock boilerplate. It contrasts this approach with reflection-based mocking in Objective-C and discusses how code generation fits Swift's type-safety goals.

### Source excerpt

Please note that this post won't go over the basics of Cuckoo, as the README provides a great introduction to the library. Do you write unit tests? You should. Writing mocks for my tests seemed to be a lot easier in Objective-C. OCMock makes great use of Objective-C's dynamic nature and it makes mocking a breeze. However, the OCMock website has this to say: Disappointing. Accurate. Alright, off to find an alternative. The best that I could find was SwiftMock, but that came with an even sharper let-down: It seems that Swift's lack of reflection means that we'll be doomed to doing things manually and rewriting the same type of code, again and again. So, I resorted to rolling my own mocks. It's not that bad. Really. I built a little mocking framework of my own based off of a Mock protocol and use of Swift's basic reflection, and all was happy in the world of TDD. When you're writing a lot of code and all of the tests that should come with it, all of the time spent writing boilerplate for your mocks gets tiring. I was hungry for something more efficient. Then, I was introduced to Cuckoo. Cuckoo is a mocking framework for Swift that uses code generation to create the boilerplate that you'd otherwise be writing yourself. It comes with a lot of functionality that I think would be far too tedious and repetitive to do on your own. It also ensures consistency, which is something that I've found to be sorely lacking in the world of hand-rolled mocks. Code Generation versus Reflection Most programming languages use reflection to dynamically perform things that we would otherwise have to write repetitive boilerplate for. OCMock uses reflection to create mock objects. It doesn't actually create a new class for each type you wish to mock. Reflection allows languages like Objective-C to dynamically create mocks, check for equatability, and perform JSON serialization. As of yet, this isn't an easy feat in Swift. The Swift language shuns dynamic behaviour and encourages safer methods

## Applying Systems Thinking to Software Development and Code Reviews

DevFeed: [Applying Systems Thinking to Software Development and Code Reviews](<https://devfeed.tech/articles/lessons-learned-from-systems-thinking-22318.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/systems-thinking/>)

Author: Keegan Rush

Published: 2017-09-20T00:00:00Z

Content type: opinion

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [systems](<https://devfeed.tech/topics/systems.md>), [Development](<https://devfeed.tech/topics/development.md>), [Code review](<https://devfeed.tech/topics/code-review.md>), [engineering-culture](<https://devfeed.tech/topics/engineering-culture.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [code-review](<https://devfeed.tech/tags/code-review.md>), [developer](<https://devfeed.tech/tags/developer.md>), [development](<https://devfeed.tech/tags/development.md>), [productivity](<https://devfeed.tech/tags/productivity.md>), [software](<https://devfeed.tech/tags/software.md>), [systems](<https://devfeed.tech/tags/systems.md>)

### AI overview

The author shares lessons from an Agile Poznan meetup on systems thinking and its application to software development. The article argues that improving systems, safeguards, and development pipelines can address recurring problems, reduce blame and micromanagement, and help teams focus code reviews on more meaningful issues.

### Source excerpt

I was lucky enough to attend my first meetup in Poland this month: Agile Poznan. The talk was on Systems Thinking, a topic that bored me in college but fascinated me when I entered the real world. Applying systems thinking can reveal the origins behind events and behaviors we see every day. Using this clarity can make you a better software developer, and a better asset to your organisation in general. Here are some of my insights from the meetup. A quick definition A system is made up of elements that share a purpose. Elements can be people, machines, or other sub-systems within the system. The elements are connected within the boundary of a system. You can identify a system through its elements and the connections between them, its purpose, and its boundary. Identifying the elements is easy. The purpose, boundary, and connections might be a little harder to find. It's not the fault of the person. It's the system. A surprising majority of problems can be mitigated when you stop blaming the person that made a mistake, and build your system so that the problem won't happen again. The person is just the messenger that's showing you that the house is burning down. Code reviews used to occasionally frustrate me before I came to this way of thinking. I'd find myself reiterating the same comments repeatedly. I want to learn, and I want to help others to learn, but learning gets diluted when we are forced to focus on miniscule issues like styling in a code review and miss the real opportunities for growth. I see using a tool like Danger, or adding any linting or code formatting to your development pipeline, as a great application of systems thinking. You're building safeguards in the system that will allow you to focus on more important and nuanced issues. The performance of an organisation depends on the quality of systems, not of individuals. The overhead of trying to micromanage every individual in an organisation outweighs the possible benefits. You simply can't maintai

## iOS: Animating your own toast view

DevFeed: [iOS: Animating your own toast view](<https://devfeed.tech/articles/ios-animating-your-own-toast-view-22316.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/iOS-Toast-View-Animation/>)

Author: Keegan Rush

Published: 2017-08-31T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [iOS](<https://devfeed.tech/topics/ios.md>), [App](<https://devfeed.tech/topics/app.md>), [ui](<https://devfeed.tech/topics/ui.md>)

Tags: [animation](<https://devfeed.tech/tags/animation.md>), [app](<https://devfeed.tech/tags/app.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [ios](<https://devfeed.tech/tags/ios.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [translation](<https://devfeed.tech/tags/translation.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

A tutorial on creating and animating a short-lived toast view in an iOS app without a third-party dependency. It explains how to position the view above the navigation bar, use a transform translation to animate it into place, and reset the transform when the animation completes.

### Source excerpt

A toast view is a small, short-lived popup provides a small bite of information (see what I did there?) to the user. It's an Android paradigm, but if you're working on an iOS app that has an Android component, the chances are high that you have been or will be asked to implement one at some point. So you might as well learn how to make one simply without having to pull in a 3rd-party dependency, right? Well, let's get started then. I'll focus on helping you get the basics of the animation down. The actual look of the view can be left to more talented designers than myself. Animating a drop down view from the navigation bar We're going to animate the toast coming down from the navigation bar, but the lessons learnt needn't be tied to the exact implementation. Create your animations as you wish. This is the final result that we're hoping to achieve: Animating the transform It's generally a bad idea to modify a view's frame just for the purpose of animation. We'll animate the transform instead. The responsibility of a view's frame is setting the view's place in the view hierarchy. The responsibility of the transform is to add any modifications to how the view should look to the user. You can modify the view's transform to rotate it, scale it, or reposition it. We're going to use it to reposition the view on the screen and animate that change. @IBAction private func startToastAnimation(_ sender: Any) { let toastView = createToastView() view.addSubview(toastView) animate(toastView: toastView) } private func createToastView() -> UIView { // 1. let toastViewHeight = CGFloat(80) let toastView = UIView(frame: CGRect(x: view.frame.origin.x, y: -toastViewHeight, width: view.frame.width, height: toastViewHeight)) toastView.backgroundColor = .green return toastView } private func animate(toastView: UIView) { UIView.animate(withDuration: 1.0, animations: { // 2. toastView.transform = toastView.transform .translatedBy(x: 0, y: toastView.frame.height) }, completion: { _ in // 3. UI

## iOS: Working with Images from a Server

DevFeed: [iOS: Working with Images from a Server](<https://devfeed.tech/articles/ios-working-with-images-from-a-server-22307.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/Swift-Send-Image-To-Server/>)

Author: Keegan Rush

Published: 2017-07-04T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [iOS](<https://devfeed.tech/topics/ios.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [Back end](<https://devfeed.tech/topics/backend.md>), [API](<https://devfeed.tech/topics/api.md>), [Server](<https://devfeed.tech/topics/server.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [backend](<https://devfeed.tech/tags/backend.md>), [http](<https://devfeed.tech/tags/http.md>), [ios](<https://devfeed.tech/tags/ios.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [swift](<https://devfeed.tech/tags/swift.md>)

### AI overview

A tutorial showing how to build a Kitura Swift backend with REST endpoints that receive images and return the most recently received image, then connect it to an iOS app. It explains converting images between UIImage and Data when sending them over the service.

### Source excerpt

If you're a mobile app developer, at some point in time you're going to need to interact with a backend. One of the tasks you might need to do is to retrieve and display images from a server, or submit an image to that server. What format should the image be in when you're submitting it? How do you convert bytes received from a service call into an image? Let's build the entire stack from the server to an iOS App to find out how. Setting up a backend We'll start off by building a Kitura server that provides a RESTful API to do two things: Receive images from a client Provide the most recent image that was received to a client I've put the finished server up on my Github. Create the server project Make a directory, and init a new executable Swift package. mkdir mkdir SwiftImageServer && cd SwiftImageServer swift package init --type executable Edit your Package.swift file to specify that you require the Kitura package. import PackageDescription let package = Package( name: "SwiftImageServer", dependencies: [ .Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1) ]) You can run a swift package fetch and you should see SwiftPM cloning Kitura and everything that it requires. Spin up a xcodeproj with swift package generate-xcodeproj and let's get coding! Create a Kitura server The backend is going to be super simple, so we'll just be working in main.swift. Let's start off by adding all the boilerplate that we need: import Kitura import Foundation // Create a Router that we can use to create REST endpoints let router = Router() // Specify that we want an HTTP server that we can reach with http://localhost:8090 Kitura.addHTTPServer(onPort: 8090, with: router) // Start the server Kitura.run() I love how easy it is to create something these days. Three lines of code and you have a server running. It's a shame that it can't do much. Let's fix that. Returning an image from a GET endpoint var latestImage: Data? = nil // http://localhost:8090/latestImage router

## Using Vim for Swift Development with Syntastic and swift.vim

DevFeed: [Using Vim for Swift Development with Syntastic and swift.vim](<https://devfeed.tech/articles/vim-and-swift-development-in-a-post-apocalyptic-world-22311.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/Vim-Swift/>)

Author: Keegan Rush

Published: 2017-06-22T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Swift](<https://devfeed.tech/topics/swift.md>), [Vim](<https://devfeed.tech/topics/vim.md>), [Syntax Highlighting](<https://devfeed.tech/topics/syntax-highlighting.md>), [Xcode](<https://devfeed.tech/topics/xcode.md>)

Tags: [plugin](<https://devfeed.tech/tags/plugin.md>), [swift](<https://devfeed.tech/tags/swift.md>), [syntax-highlighting](<https://devfeed.tech/tags/syntax-highlighting.md>), [vim](<https://devfeed.tech/tags/vim.md>), [xcode](<https://devfeed.tech/tags/xcode.md>)

### AI overview

A tutorial for configuring Vim to work on Swift projects when Xcode is unavailable or malfunctioning. It uses the Syntastic and swift.vim plugins to compile SwiftPM packages on save, show errors and warnings in Vim, and enable SwiftLint checking.

### Source excerpt

Disclaimer: I don't advocate using Vim seriously as your primary development environment. As powerful as it is, Vim remains a text editor, not an IDE. I ran into some Xcode problems the other day where I lost syntax highlighting and code completion in Swift files. What should we do when Xcode just doesn't work? I joked that at this point, it might be easier to just use Vim for my Swift development. Well... It's not hard to use an arbitrary text editor to write some code and then run it through a compiler. For this setup, we want something a little bit more pleasant to use. The passionate programmers that we are, we want to be able to work on non-trivial Swift projects, with or without Xcode, from the comfort of our own home or in a post-apocalyptic nuclear bunker (hey, let's not rule anything out). We want: Those sweet Vim keybindings An easy way to compile and run code Resilience against Xcode temper tantrums Syntax highlighting that works. All. The. Time. We'll be using some Vim plugins. You'll need some means of plugin management. I'll be using Pathogen. Syntastic Syntastic provides syntax highlighting in Vim for many languages. It does this by associating checkers with a particular language. When you save the file you're working on, it runs the appropriate checkers. A checker is essentially an adapter between the world of Vim with Syntastic and your language with its compiler or linter. What we want to accomplish through Syntastic is to easily compile a project when the current file is saved and surface any errors or warnings inside Vim. Using Pathogen, install Syntastic. cd ~/.vim/bundle && \ git clone --depth=1 https://github.com/vim-syntastic/syntastic.git swift.vim swift.vim has a SwiftPM checker that will compile a project and a SwiftLint checker to remind us that we occasionally have no idea what we're doing. Install swift.vim: cd ~/.vim/bundle && \ git clone --depth=1 https://github.com/keith/swift.vim SwiftPM Go to a Swift project containing a Package.swif

## Common RxSwift Problems and Their Solutions

DevFeed: [Common RxSwift Problems and Their Solutions](<https://devfeed.tech/articles/half-baked-solutions-to-common-rxswift-problems-22303.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/Half-Baked-Solutions-To-Common-RxSwift-Problems/>)

Author: Keegan Rush

Published: 2017-05-23T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [iOS](<https://devfeed.tech/topics/ios.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [ui](<https://devfeed.tech/topics/ui.md>)

Tags: [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [ios](<https://devfeed.tech/tags/ios.md>), [merge](<https://devfeed.tech/tags/merge.md>), [module](<https://devfeed.tech/tags/module.md>), [programming](<https://devfeed.tech/tags/programming.md>), [property](<https://devfeed.tech/tags/property.md>), [swift](<https://devfeed.tech/tags/swift.md>), [ui](<https://devfeed.tech/tags/ui.md>), [validation](<https://devfeed.tech/tags/validation.md>)

### AI overview

A tutorial describing solutions to several RxSwift challenges in iOS development, including UIKit interaction through RxCocoa, merging multiple observables, and conditionally triggering an observable based on validation.

### Source excerpt

I've been using RxSwift in some of my latest iOS projects. While I feel that it's provided elegant UI binding and a natural feel to asynchronous programming, I have to admit that it came with numerous growing pains. I struggled to find documented solutions to some of the challenges I was facing, as RxSwift is not as widely adopted as its more affluent Java and .Net counterparts. Here are some of those hurdles that I faced, along with my solutions. Why can't I access the tap method of my UIButton? One of the greatest benefits of Rx is its UI binding capabilities. So you must imagine how peeved off I was when I couldn't do something as simple as bind some logic to taps on a UIButton. Luckily, the solution is just as simple as the problem. import UIKit import RxSwift import RxCocoa let button = UIButton() button.rx.tap.bind { print("That wasn't too hard, was it?") } See that sneaky import RxCocoa at the top there? RxSwift functionality relating to UIKit is found in the RxCocoa module. The rx property on UIButton that I'm using in the snippet comes from RxCocoa. You can find it on most UIKit objects. It's what powers RxSwift's interaction with UIButton, UITableView, UIImageView, and all of the other usual suspects. You can find an RxSwift extension on most UIKit objects - just look out for the object plus Rx.swift - e.g. UITableView+Rx.swift. How do I combine the output from multiple observables into one? If you have data from multiple sources, and want to treat them as one, you need to merge them. let cars = Observable.from(["Nissan", "Ford", "BMW"]) let tanks = Observable.from(["Tiger II", "T-44", "Panther"]) let bikes = Observable.from(["Ducati", "Honda", "Kawasaki"]) let landVehicles = Observable.of(cars, tanks, bikes).merge() landVehicles.subscribe(onNext: { print($0) }) /* Output: Nissan Ford Tiger II BMW T-44 Ducati Panther Honda Kawasaki */ First, we combine the three observables using of. You can use the of operator on any list of items to create an Observable

## Lessons Learned From The Entelect Way

DevFeed: [Lessons Learned From The Entelect Way](<https://devfeed.tech/articles/lessons-learned-from-the-entelect-way-22304.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/Lessons-Learned-From-The-Entelect-Way/>)

Author: Keegan Rush

Published: 2017-05-08T00:00:00Z

Content type: opinion

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Software Engineering](<https://devfeed.tech/topics/software-engineering.md>), [Agile](<https://devfeed.tech/topics/agile.md>), [Resilience](<https://devfeed.tech/topics/resilience.md>), [engineering-culture](<https://devfeed.tech/topics/engineering-culture.md>)

Tags: [agile](<https://devfeed.tech/tags/agile.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [resilience](<https://devfeed.tech/tags/resilience.md>), [software-engineering](<https://devfeed.tech/tags/software-engineering.md>)

### AI overview

A software engineer reflects on lessons from an Entelect Way workshop, focusing on software delivery principles, understanding clients' underlying goals, continuous communication, resilience, and team learning.

### Source excerpt

Software engineering and coding are two very different concepts. As a software engineer, I write code on a daily basis, but the value that a good software engineer provides to a business is so much more. This is emphasised by The Entelect Way. What is The Entelect Way? I'm a software engineer at Entelect, a software engineering and solutions company based in South Africa. The Entelect Way is a set of guiding principles for software delivery that can be used to help guide your decisions, activities, and behaviour as a professional software engineer. The principles are broken down into the following areas of focus: Agile Planning and Development Software Engineering Quality Practices Individual Growth Team Engagement Relationships Value Adding Activities First Class Service Delivery The Workshop A few weeks ago, my team attended a workshop on The Entelect Way with a few teams based at other clients. We took a deeper look at each of the principles and were encouraged to find ways to apply these principles in our day to day activities. Our Findings We were asked to discuss Value Adding Activities. We chatted about each team's strengths and weaknesses around the points raised during the workshop. I realized what our team does well - and where we need some major improvement. While we didn't stay entirely on topic of Value Adding Activities, we did manage to learn a lot from each other that we then compiled into a list. Here's the best picks across our three teams: Focus on your client's 'why' You can take action on your client's what, or you can take action on their why. Try to find the why, and use that as your guide. Imagine you're fetching data from a service and displaying that to the user. If someone asks you to attempt to make the service call three times in the case of failure before displaying an error message, they're asking for the what. The why is likely to be something along the lines of "I don't want the user to visually experience errors when the server goes

## Android Development Through the Eyes of an iOS Developer

DevFeed: [Android Development Through the Eyes of an iOS Developer](<https://devfeed.tech/articles/android-development-through-the-eyes-of-an-ios-developer-22302.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/Android-Development-Through-the-Eyes-of-an-iOS-Developer/>)

Author: Keegan Rush

Published: 2017-03-16T00:00:00Z

Content type: opinion

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [Android Studio](<https://devfeed.tech/topics/android-studio.md>), [Development](<https://devfeed.tech/topics/development.md>), [Xcode](<https://devfeed.tech/topics/xcode.md>), [Objective-C](<https://devfeed.tech/topics/objective-c.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [developer](<https://devfeed.tech/tags/developer.md>), [ios](<https://devfeed.tech/tags/ios.md>), [ios-development](<https://devfeed.tech/tags/ios-development.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>), [xcode](<https://devfeed.tech/tags/xcode.md>)

### AI overview

An iOS developer shares initial, explicitly opinion-based observations from trying Android development. The comparison covers Android Studio versus Xcode, Activities versus view controllers, device and screen-size fragmentation, version support, and XML-based localization.

### Source excerpt

I've recently dipped my toes into Android development to see the differences in environment and tooling as compared to iOS development. While I haven't done much as of yet, I hope to ship some Android apps in the future alongside some iOS ones. I figured it was time to understand the platform so that I can better relate to the woes of Android development. Disclaimer Note that this is entirely opinion based, and these are only initial opinions. Understanding of any language or SDK fleshes out over time, and I'm looking forward to see how my understanding and opinions change as I write more and more Android code. The Findings I expected to see much more boilerplate and repetitive code as opposed to iOS, where we have the ability for frameworks to be more powerful and simple at the same time by tapping into the Objective-C runtime. While this was true to some extent, I'd like to talk more about some of the other differences I noticed: IDE If you're ever used a Jetbrains IDE or plugin, you'll love Android Studio. It's such a pleasure having the platform's standard IDE being one by Jetbrains. I've been burned by Xcode too many times, namely due to bugs and lack of refactoring tools, and I for one am quite pleased with Android Studio. Activities vs ViewControllers Where you'd use a UIViewController in iOS, you're using Activities in Android. While passing data through Intents is not perfect in my eyes, I prefer it to using the prepareForSegue method on iOS to see if the segue identifier matches the one you expect and then configuring the destination view controller. However, if you don't need to pass data around, I must say that handling all your segues in a Storyboard without writing any code is very convenient. Supporting different platforms and devices I'm starting to see that we have it so easy on iOS when it comes to supporting other devices. There's an almost unlimited number of hardware and screen size combinations for Android. Many iOS developers can name almost e

## Using Multiple Author Identities With Git

DevFeed: [Using Multiple Author Identities With Git](<https://devfeed.tech/articles/using-multiple-author-identities-with-git-22310.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/Using-Multiple-Author-Identities-With-Git/>)

Author: Keegan Rush

Published: 2017-02-15T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Git](<https://devfeed.tech/topics/git.md>), [configuration](<https://devfeed.tech/topics/configuration.md>), [bitbucket](<https://devfeed.tech/topics/bitbucket.md>), [GitHub](<https://devfeed.tech/topics/github.md>)

Tags: [bitbucket](<https://devfeed.tech/tags/bitbucket.md>), [charity](<https://devfeed.tech/tags/charity.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [git](<https://devfeed.tech/tags/git.md>), [github](<https://devfeed.tech/tags/github.md>), [version-control](<https://devfeed.tech/tags/version-control.md>), [work](<https://devfeed.tech/tags/work.md>)

### AI overview

This tutorial explains how to manage multiple author identities in Git. It covers global and repository-specific user configuration and notes that changing an author after committing modifies Git history.

### Source excerpt

How do you manage git credentials for different organizations? You may have some projects you work on at work that has a pre-push hook to ensure that your email is part of the correct domain. You might have your own personal projects, some of which might also use difference email addresses. Or, just maybe, you have a secret identity that you don't want your other repositories to know about. How does one manage this schizophrenic multiple personality disorder that we call Version Control? If I commit with the wrong email at work, I won't be allowed to push to our internal Bitbucket server. If I commit with the wrong email on one of my personal Github repositories, I end up with this ugly situation: The commits that don't have my image were made with my name but with an unknown email. So GitHub doesn't know that it was really me and does not link it to my Github identity. What I need to do is to tell git to use the email that Github expects. How to assume multiple identities Git commits have an author with a name and an email. Run git log in a repository you've committed to recently to see some of the metadata of your commits: commit bd294498cbd5c67b51096518ce62c9204068be2c Author: Bruce Wayne <bruce.wayne@wayneenterprises.com> Date: Tue Feb 14 19:58:34 2017 +0200 Plan attendance to charity events Git uses the user name and email set in your global .gitconfig file, located at ~/.gitconfig or C:\Users\MyUser\.gitconfig. The [user] block sets the author name and email address for all commits. You can set it by manually editing the file: $ vim ~/.gitconfig [user] name = "Bruce Wayne" email = "bruce.wayne@wayneenterprises.com" Git also provides a command to update global settings. $ git config --global user.name "Bruce Wayne" $ git config --global user.email bruce.wayne@wayneenterprises.com This modifies the global .gitconfig for you. Specifying identities at the repository level So now that you've created your global identity, how about adding a different one for a parti

## The Difference Between An Adapter And A Wrapper

DevFeed: [The Difference Between An Adapter And A Wrapper](<https://devfeed.tech/articles/the-difference-between-an-adapter-and-a-wrapper-22308.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/The-Difference-Between-an-Adapter-and-a-Wrapper/>)

Author: Keegan Rush

Published: 2017-01-30T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [adapter-pattern](<https://devfeed.tech/tags/adapter-pattern.md>), [bridge](<https://devfeed.tech/tags/bridge.md>), [compatibility](<https://devfeed.tech/tags/compatibility.md>), [interface](<https://devfeed.tech/tags/interface.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [library](<https://devfeed.tech/tags/library.md>), [object](<https://devfeed.tech/tags/object.md>), [programming](<https://devfeed.tech/tags/programming.md>), [third-party](<https://devfeed.tech/tags/third-party.md>), [toolbox](<https://devfeed.tech/tags/toolbox.md>)

### AI overview

This article explains the difference between the adapter pattern and wrappers. Adapters bridge incompatible interfaces by transforming input, while wrappers encapsulate code to simplify and constrain its interface, often around external libraries.

### Source excerpt

The adapter pattern and wrappers each solve common but distinct problems. Their common usage and similarities in implementation, however, can lead to confusion. Both terms seem to be used interchangeably when in fact there are a few key differences. The adapter pattern and wrappers are two very useful tools and you can benefit from having them properly labeled in your toolbox. Definition Adapter: An adapter allows code that has been designed for compatibility with one interface to be compatible with another. An adapter accomplishes this by transforming the input meant for Interface A into compatible input for Interface B. It is a bridge between two existing interfaces. Wrapper: A wrapper encapsulates and hides the complexity of other code. The most common use of a wrapper is in the Facade pattern. Third-party code can be hard to use due to the fact that the exposed interface is made to accommodate many use cases. When you are only concerned about a subset of the features or the exposed interface, or you find that using the library is hard or tedious, then what you need is to wrap it in a simpler, more constrained interface. Differences Intention: The end product may look similar but the intention is different. A wrapper as used in the Facade pattern is intended to simplify an interface to an external library. An adapter is intended to bridge the disconnect between one interface and another. You may look at a new library that you wish to use and write a wrapper to simplify and streamline its use. You may look at an interface, internal or external, that your existing code needs to conform to, and write an adapter to do that. Composition: A wrapper contains another object and wraps around it. It has the the sole responsibility of moving data to and from the wrapped object. An adapter doesn't necessarily contain or simplify an object, although this can be a secondary benefit of using adapters. An adapter transforms input to make it match the input required by another in

## Server Side Swift With Kitura And Bluemix

DevFeed: [Server Side Swift With Kitura And Bluemix](<https://devfeed.tech/articles/server-side-swift-with-kitura-and-bluemix-22306.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/Server-Side-Swift-With-Kitura-And-Bluemix/>)

Author: Keegan Rush

Published: 2017-01-03T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Tutorial](<https://devfeed.tech/topics/tutorial.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [Platform as a Service (PaaS)](<https://devfeed.tech/topics/platform-as-a-service-paas.md>), [Code](<https://devfeed.tech/topics/code.md>), [Framework](<https://devfeed.tech/topics/framework.md>), [Cloud](<https://devfeed.tech/topics/cloud.md>), [Open Source](<https://devfeed.tech/topics/open-source.md>)

Tags: [app](<https://devfeed.tech/tags/app.md>), [cloud](<https://devfeed.tech/tags/cloud.md>), [framework](<https://devfeed.tech/tags/framework.md>), [infrastructure](<https://devfeed.tech/tags/infrastructure.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [platform-as-a-service-paas](<https://devfeed.tech/tags/platform-as-a-service-paas.md>), [programming](<https://devfeed.tech/tags/programming.md>), [servers](<https://devfeed.tech/tags/servers.md>), [swift](<https://devfeed.tech/tags/swift.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

### AI overview

A tutorial on deploying a server-side Swift application with Kitura on IBM Bluemix. It covers configuring Bluemix, using Swift Package Manager and Kitura, building a service that interprets cron expressions, and enabling continuous delivery.

### Source excerpt

IBM Bluemix is a cloud Platform as a Service solution that enables you to concentrate on writing your application while Bluemix handles most of the DevOps-y stuff like the networks, servers, storage, and software dependencies. It supports several programming languages, including Swift. It's also easy to use - all you'll need to manage your service is a web browser. You can even write your Swift code in your browser in the IBM Swift Sandbox. This tutorial will take you over the basics of getting started with Kitura and Bluemix. First, we'll set up Bluemix so we can upload our app and spin up a server with minimal effort when we're ready. Then we'll work through Swift Package Manager and Kitura step by step. Once some familiarity has been established, we'll build something useful and upload it to Bluemix. We'll build a small service that takes a cron expression and returns a human readable description of that expression, using the SwiftCron package from Swift Package Manager. Setting up IBM Bluemix To get started, head over to IBM BlueMix and sign up for a free 30 day trial. When you sign in you'll be asked to name your organization, which is essentially your team that you can add other people to, and choose its location. Just choose the location that's closest to you - the options are limited to where Bluemix currently has infrastructure set up. You'll then be asked to set up a space, which is how Bluemix organizes apps and services. You'll then be navigated to the dashboard which is, understandably, empty. Click on Create App, and we'll make things a little bit more lively. Bluemix is built off of Cloud Foundry, which is an open-source Platform as a Service(PaaS). Bluemix then provides boilerplate for a few popular web frameworks like Python's Flask framework to get you started instantly. Unfortunately, a boilerplate offering doesn't yet exist for Swift, so we'll be scrolling down past these enticing options to the Cloud Foundry Apps section. Choose Runtime for Swif

## A Caution On Superfluous Code

DevFeed: [A Caution On Superfluous Code](<https://devfeed.tech/articles/a-caution-on-superfluous-code-22301.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/A-Caution-On-Superfluous-Code/>)

Author: Keegan Rush

Published: 2016-12-15T00:00:00Z

Content type: article

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [Library](<https://devfeed.tech/topics/library.md>), [SDKs](<https://devfeed.tech/topics/sdks.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [bugs](<https://devfeed.tech/tags/bugs.md>), [code](<https://devfeed.tech/tags/code.md>), [improvements](<https://devfeed.tech/tags/improvements.md>), [library](<https://devfeed.tech/tags/library.md>), [performance](<https://devfeed.tech/tags/performance.md>), [sdks](<https://devfeed.tech/tags/sdks.md>), [standard-library](<https://devfeed.tech/tags/standard-library.md>), [swift](<https://devfeed.tech/tags/swift.md>)

### AI overview

The article cautions developers against writing superfluous code that adds complexity without changing product behavior. It attributes this problem partly to insufficient understanding of a language or library, and recommends using existing standard-library and platform SDK functionality when it meets the need. A Swift NotificationCenter example shows how an unnecessary registration flag can be removed because removing an observer is safe even when it is not registered.

### Source excerpt

The line of code that the developer can write the fastest, the line of code that the developer can maintain the cheapest, and the line of code that never breaks for the user, is the line of code that the developer never had to write. - Steve Jobs Superfluous code is code that is written unnecessarily. It is code that has all the added complexity of valuable code, but it adds no value of its own. If you were to remove it, the product would behave exactly the same. I can think of a few causes of superfluous code: Improper understanding of the toolset If a developer doesn't properly understand the language or the library that is being used, how can he be certain that the code he writes is suited to the task at hand? Oftentimes code is written that duplicates functionality included in the standard library. Now the same functionality exists in two different places: in your code base, and in your library. It has to be maintained twice. And tested twice. For complex algorithms, you're losing the benefit of years and years of bug fixes and performance improvements to the implementation that's available to you through your toolset. Take the time to understand what is available to you. If it suits your needs, use it. Don't write superfluous code when you can write no code and gain the same value from your platform's SDKs. But, if you don't know what is available to you, you're doomed to repeat the bugs of the past. I recently came across the following Swift code: import Foundation class Foo { var isRegisteredForNotifications = false init() { registerForNotifications() } func registerForNotifications() { isRegisteredForNotifications = true NotificationCenter.default.addObserver(forName:Notification.Name(rawValue:"MyNotification"), object:nil, queue:nil, usingBlock:notificationWasFired) } func notificationWasFired(notification: Notification) { /* . . */ } deinit { if isRegisteredForNotifications { NotificationCenter.removeObserver(self) } } } NotificationCenter is a class in Sw