An easy guide to object rest/spread properties in JavaScript

Merging multiple JavaScript objects is a frequent task. Unfortunately JavaScript is sloppy at providing a convenient syntax to do the merge. At least until now. In ES5 your solution is _.extend(target, [sources]) from Lodash (or any alternative), and ES2015 introduces Object.assign(target, [sources]). Luckily object spread syntax (an ECMASript proposal at stage 3) is a step forward how to manipulate objects, providing a… Continue reading

7 architectural attributes of a reliable React component

I like how React embraces component-based architecture. You can compose complex user interfaces from smaller pieces, take advantage of components reusability and abstracted DOM manipulations. Component-based development is productive: a complex system is built from specialized and easy to manage pieces. Yet only well designed components ensure composition and reusability benefits. Despite the application complexity, hurry to meet the deadlines and unexpectedly changing requirements, you… Continue reading

7 tips to handle undefined in JavaScript

When I started to learn JavaScript about eight years ago, a bizarre situation for me was the existence of both undefined and null that represent empty values. What is the clear difference between them? They both seem to define empty values, and moreover the comparison null == undefined evaluates to true. Most of the modern languages like Ruby, Python or Java have a single null value… Continue reading

Announcing Voca: The ultimate JavaScript string library

Open source changed the software development. And it changes the developers. Many libraries, apps, servers, and much more are powered by open source software. Catch the open source wave I always wanted to create and maintain an open source project. It is a must experience for every software developer. This way I started to work on a JavaScript library called Voca. It's main scope is… Continue reading

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