Set up multi-container environment using Docker Compose

I remember this time when I discovered Vagrant. The magic behind this tool and the general idea of scaffolding the whole environment using single command was pretty genius. Moreover, I had programmed on Windows and thankfully I could get rid of the XAMP and any other Windows-oriented web server packages.

In my previous job, my boss showed me a tool called Docker. I instantaneously got the point of the concept behind it and I started exploring the big universe of the possibilities of use. In this article, I’m going to show the most common use-case for docker – a proposed local environment suited for PHP application development.

This article is devoted to the configuration rather than explanation what the Docker really is. I would like to show the actual use-case rather than showing my point of view – I’ll follow it in one of the next articles.

Read more →

I’ve finished studies. Here are some of my thoughts

A long time since my last article. During the last few months, I was fully involved in my last big project at my university. Dozens of articles and books, hundreds of visited pages and thousands of words later I had finished it and a few weeks later I defended my master’s thesis.

Since I took a short break from almost every activity, I had a lot of time for thinking. When I look at 2012, I see the young guy who knows everything he needs and he wants to only the paper to confirm it. Now, in 2018, I’m equipped with knowledge, a completely new point of view and goals in life. But it wasn’t so obvious even during my education.

Some people asked me what studies gives me at all. Was it worth to spend almost every weekend for the last 6 years at the university? Do I feel the difference? There are no simple answers to these questions because they depend on the approach. And it changed over time. But let me sum up.

Read more →

The code is a common good, so be responsible for him

I joined to the project that was developed by one guy. He was an amazing developer with plenty of ideas and skills. He had also the best knowledge about the system – its domain, architecture, used solutions, hidden tricks, and workarounds. In every single task, I needed his support because I didn’t understand how things worked. My main goal was to retrieve as much knowledge as possible from his head. The reason was simple – his contract is ending in a month. I wish I didn’t know about it before.

The project had the long to-do list of features. Some of them were partially implemented. Some other functionalities had specified time–frame because of the seasonal nature of the project. Everything was important from the business point of view.

There were no tests, no code’s style guide, no documentation (besides a few out of date README.md files across repository). I didn’t want to touch anything because the code was unstable and cause a lot of side–effects. After one month of torment, I thought – “f*ck it, let’s make it works”.

Read more →

Did your team define own code deprecation strategy?

I didn’t always work in a larger team. At the beginning of my journey as a computer programmer, I was the only one person in a project. It meant that I had had a free-hand (or semi-free-hand) to choose how I could write a code and which solutions I could use. From day to day I could perform a little revolution in the codebase. No consequences and no problems because the only user of the code was me.

Although this situation might look as the best case for a programmer, it doesn’t. Especially for the junior programmer. You have no opportunity to learn from someone else. You can’t validate your ideas and thoughts with others. Ultimately your only friends and co-workers are Google and Mr. StackOverflow.

After some time, I got a new job and I started to work as a part of the team. As a new person in the company, I had tons of ideas and tools that we could use in a project to make our work better, more pleasant and easier. It was relatively easy to introduce new features into the codebase. On the other hand, it was almost impossible to remove the old ones. Why?

Because we didn’t have the code deprecation strategy.

Read more →

Don’t use properties and methods from outside the interface

It may sound obvious or even weird for people who programming in statically typed or compiled languages. In my work, I use PHP which is a dynamically typed language with optional strict typing introduced in version 7. At the beginning of my journey with PHP, I didn’t care so much about typing. I had a trivial cause — they didn’t exist yet.

I used to write a code without thinking about types. It was convenient and fast. Furthermore, it allowed writing proxy functions which recognize parameters type and it runs the proper function. Yes, overriding doesn’t exist in PHP.

But things changed when I discovered polymorphism. The magic keyword Interface that allows us to define the mandatory set of features in the object. The picture of writing a code without worrying about missing methods was incredible. I still didn’t understand one thing yet. How interfaces help me since I can pass everything on the function call?

This question lied a long time in my head until I discovered I can define the required type of passed object. Since that time, I changed completely the way how I write the code.

Read more →

Why I removed my old accounts and why you should too

Whenever people say about New Year’s changes they, mainly think about resolutions, plans and set up goals. But this is also a great time to small retrospective both your personal and digital life.

Let’s talk about the digital once.

Do you realize how many registrations have you performed over the last year? Or over the last 5 years? Who did you give your email, personal data, photos, documents or other files to? Too often, it’s too much to know about all this.

Think about each website, application or service which you used and you didn’t use it for a long long time. Social profiles, cloud storage, dedicated tools and the other software. In each of them, you probably left some data. Maybe it’s not relevant and doesn’t have any value for you, but this information is about you.

What if one day, someone will get access to all of these data you left in the Internet?

Read more →

Inbox zero – efficient way to manage emails

Every day at least 30 new messages land in my mailbox. Newsletters, reminders, status updates, mentions, recommendations and even personal or business messages – each of them need my time and an attention. And no one besides me is responsible for handling them.

I had my very first email account on the public news site. I received tons of advertising messages until I got the invitation to the Gmail. This mail service was capable of identifying unwanted messages. That was what I have been looking for for a long time.

Although I receive a bunch of messages each day (more important than spam or advertisements), at the end of the day my inbox is empty. Thanks to Inbox Zero approach, I manage my matters without wasting time. It helps me preventing myself from being overwhelming by a number of emails.

Read more →

Building the associative array – ideas

When we talk about arrays we usually mean the vector of something – primitives, objects or even arrays. But there are a lot of situation when we need to carry extra information with our data. We can use nested arrays but it doesn’t cause that the specific item within the array will be easy to identify. To achieve it we should use custom keys. They provide easy access to any element of the array as long as we know the key corresponding with that value.

There are some reasons why we can use associative arrays instead of simple vectors, e.g. readability. Named keys are also more meaningful than numeric indexes. Instead of thinking about the whys, image the situation when we could use a hashmap. Let’s focus on how we can build the associative array from a vector.

Read more →

What is idempotence?

If you frown after reading idempotence, don’t worry. Although this word sounds unusual it conceals a simple mathematics property. Needless to say, this characteristic has also a big meaning in Computer Science.

Idempotence operation is an operation that can be applied multiple times without changing the result beyond the initial application. It may sound difficult but after a couple of examples, the general concept will be obvious.

Read more →

Why should you return early?

When I started my journey as a computer programmer, I had written my code in various way. In most cases, I translated requirements into specific conditions and statements, but I hadn’t taken too much care of readability or quality of my code. “It works, that’s it” – and the code base grew and grew in time. Thousands of written methods later, I had discovered that a lot of these little pieces of logic could look better if I reverse some condition within them. Unconsciously, I’ve started following the rule which I had later called the “fail fast” rule, and subsequently “return early”.

I realized I hadn’t had the one preferred way to check conditions within the single method. Sometimes I let execution if the expression was true. Another time I had waited for the false result to show the error message before the main part of the code was executing. In my head, I discovered various styles of checking conditions.

Read more →