How to get a better performance when working with collections.

Software is meant to help people computing mass of calculations. It’s safe to say, that each software uses collections. How much time or resources can we safe by only making our decisions consciously?

Different use cases — different algorithms

First we need to be aware of the use case. There’s no such thing as a one-fits-all solution. We have to pick the right algorithm for current situation and there might be a couple of them. From the top of my head:


More than just equality.

It is a common question during interviews to let the interviewer know why you like a data class in Kotlin. The correct answer seems to be an equality for free. Even though it’s a really awesome feature, data class has more of them in the arsenal.

Image for post
Image for post
https://www.pexels.com/photo/woman-touching-a-mirror-3881965/

Data class

One simple keyword turned out to be a game changer in programming — data. Data classes are used to describe transfer objects. Programming is all about taking input data, processing them and returning output data. Here’s how a data class can help.

data class Man( val name: String, val surname: String, val bDate: String…


Drawing actions without creating an extra layer in layout XMLs.

Image for post
Image for post
SpotOn Transact Inc.

I love our new designs! Recently I’ve been working on user interactions. One of them is presented on the GIF above. I wanted to create a custom Drawable, so I can set a background on any view I want without wrapping it with some custom ViewGroup. An extra layer means extra calculations.

I couldn’t find any guide nor article that would help me create a Drawable object that I would be able to set as a background via XML. Like a Ripple Drawable. Unfortunately if someone counts that in this article I solved that mistery I’ll heads up a little…


Why we have to choose between safety and tidiness?

Image for post
Image for post
https://nvie.com/posts/a-successful-git-branching-model/

Quick note before I begin. GitFlow, was first published by Vincent Driessen in 2010. He suggests a simpler workflow — GitHub Flow — for the teams that do not have to support multiple versions at the same time. For further reading see the post from the author himself.

Most of the teams around the world have worked, work or will work with GitFlow. A good understanding of branch management and conflicts resolution can save a lot of trouble. …


And why it actually matters for you to use it right

Image for post
Image for post
https://www.pexels.com/photo/women-walking-in-desert-2773656/

If you still haven’t seen, find my post about design patterns in general. You can find a list of explained design patterns in one place for free! 💰 Also read the article about Factory Method 🏭 or a Builder 👨‍🏭 pattern and how it fits with Singleton.

What is it?

Singleton ☝, as the name suggests, is about creating a single instance of an object. There are programmers who claim that Singleton is an anti-pattern 🤮. Please write that down:

Singleton is design pattern ✍️ and it’s very important to understand it

It would be very inefficient to write the code that would…


Image for post
Image for post
https://www.pexels.com/photo/architecture-britain-buildings-business-114576/

If you still haven’t seen, find my post about design patterns in general. You can find a list of explained design patterns in one place for free! 💰 Also read the article about Factory method 🏭 and why it’s one of most powerful design patterns.

What is it?

Abstract Factory design pattern is an easy way of getting rid of boiler plate 🍽 code. An important rule of thumb 👍 is to remember that a Factory should create objects from the same family 👨‍👩‍👧‍👦. What do I mean? Let’s have a look at the Facebook’s dashboard. …


Image for post
Image for post

If you still haven’t seen, find my post about design patterns in general. You can find a list of explained design patterns in one place for free! 💰 Also read the article about Builder 👨‍🏭 or use Factory method with a Singleton pattern.

What is it?

Also known as “named constructor”. Why? Because in the end it’s a cleaner way of calling constructor itself. Can’t I just go and use constructor? Of course you can! Design patterns were meant to help developers solving problems, but if you see an opportunity to create a new or better approach — go for it!

Example

You can…


Image for post
Image for post

If you still haven’t seen, find my post about design patterns in general. You can find a list of explained design patterns in one place for free! 💰 Also read the article about Abstract Factory 🏭 and learn when it fits better than a Factory Method or a Builder 👨‍🏭 pattern.

Engineers need builders 👨‍👩‍👧‍👦, don’t they? Builder, in software engineering, is a creational design pattern. Why should you use builder pattern? There are at least three main reasons.

Telescoping constructors

You may be asking what is a telescoping constructor 🔭…


Image for post
Image for post

“Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing in the same way twice.” — Christopher Alexander

☝️Why bees 🐝 build their honeycombs in hexagonal form, when they could build squares or triangles? It turns out that squares are not that durable as hexagons and triangles on the other hand, are the most expensive.

“The geometry of this shape uses the least amount of material to hold…


Image for post
Image for post

I find people that still don’t fully understand SOLID principles nevertheless these rules were introduced by Robert C. Martin (Uncle Bob) in 2000. Following these principles is a must in modern programming. If you’re an experienced programmer you’ll find this article very useful too, since rhetoric for people is a fuel that feeds the fire.

SOLID

SOLID is in fact abbreviation. Of course it is, because engineers love abbreviations. What S-O-L-I-D stands for?
1. Single Responsibility Principle
2. Open-Closed Principle
3. Liskov Substitution Principle
4. Interface Segregation Principle
5. Dependency Inversion Principle

Single Responsibility Principle (SRP)

What would you say it says? Does it mean…

Maciej Najbar

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store