Make your Swift code expressive: addition operator use cases

I like reading short and expressive code. Because developer spends more time reading code than writing, expressiveness often is obligatory. Unless shortness does not obscure the intent, I favor concise expressions over longer ones. For example: Try in Swift sandbox import Foundation let greeting = "Hello, " let who = "World" let message1 = greeting + who let message2 = greeting.appending(who) print(message1) // => "Hello, World" print(message2) // =>… Continue reading

How to use correctly 'self' keyword in Swift

In Swift self is a special property of an instance that holds the instance itself. Most of the times self appears in an initializer or method of a class, structure or enumeration. The motto favor clarity over brevity is a valuable strategy to follow. It applies efficiently in most of the cases, and helps to increase the code readability, but... affects code shortness. Applying this… Continue reading

Mastering Swift: tips about array and dictionary literals

Imagine you have a bunch of delicious candies 🍬, about 20-30 items. Normally a person can eat about 2 or 3 candies per day. To deal easier with a lot of candies, it makes sense to keep them in a single place. And reasonable this place is a plastic bag or a small box, instead of keeping them spread around and messy on the table.… Continue reading

Useful details about underscore keyword in Swift

Swift is known for its ability to help creating readable and self explanatory code. Such practice is efficient, because writing meaningful code has a big impact on understanding: and as result on productivity. The language offers useful syntax to improve the readability using argument labels, or to access a tuple or structure component. For instance the following function returns a tuple that contains the minimum… Continue reading

Coding like Shakespeare: practical function naming conventions

What a piece of work is a man! How noble in reason, how infinite in faculty! Hamlet, William Shakespeare Code is prose. Clear and meaningful prose is easy to read and follow. Everyone enjoys reading such prose. The same quality should apply to source code. The way developer express his thoughts through a programming language is important. Writing code is communication: with your teammates and… Continue reading

Mastering Swift: essential details about strings

String type is an important component of any programming language. The most useful information that user reads from the window of an iOS application is pure text. To reach a higher number of users, the iOS application must be internationalised and support a lot of modern languages. The Unicode standard solves this problem, but creates additional complexity when working with strings. On one hand, the… Continue reading

Useful tips for migrating to Swift 3.0

Not long ago the 3.0 version of Swift language was released. The new version is available in Xcode 8, or you can download the compiler directly from swift.org. The new version has a lot of improvements in terms of code readability, function invocation consistency, better naming conventions and the removal of some C-style elements. In terms of readability, the NS prefix is dropped… Continue reading

The path of software development craftsmanship

The software development complexity is increasing day by day. Almost every year a new framework (like AngularJS, ReactJS) is released, new build tool (like Webpack, Rollup). Even new JavaScript versions (ECMAScript 2015, 2016 and soon 2017) are released every year! Generally the same situation exists in other fields of software development. For example mobile applications. 2 years ago Apple introduced a new programming language Swift.… Continue reading

What every JavaScript developer should know about Unicode

This story starts with a confession: I was afraid of Unicode for a long time. When a programming task required Unicode knowledge, I was searching for a hackable solution for the problem, without detailed sense what I was doing. My avoiding continued until I faced a problem that required detailed Unicode knowledge. There was no way to apply situational solutions. After applying some efforts, reading… Continue reading

The art of writing small and plain functions

The complexity of software applications is growing. The code quality is important in order to make the application stable and easily extensible. Unfortunately almost every developer, including myself, in his career faced with bad quality code. And it's a swamp. Such code has the following harmful characteristics: Functions are too long and do too many things Often functions have side effects that are difficult to… Continue reading