Write code for people

The first draft of this article was about the code-style. I wanted to show you why it is important and why we should care about it. But the longer I thought, the stronger conviction I gained, that the code-style – whatever it means – is only a way to achieve a much more important goal.

I’m a big advocate of well-quality code. Besides good architecture, I pay attention to style – consistent spacing and indentation, coherent naming convention and other rules that make the code visually better. But how to convince someone, who never took care of style before, that is it a good thing?

Read more →

Use make as task runner

During development, you probably take advantage of some extra command-line tools. In PHP world it could be a mess detector or program to check the code style. The framework you use also exposes some functionalities to clear cache, migrate database or generate documentation. All these commands are helpful but you need to look for them until you memorize the most useful ones. Sometimes you need to perform a task, like project initialization or restoring a stable snapshot of the database.
Read more →

5 stages of development as the programmer

This post is also available in: Polski 🇵🇱

5 years have passed since I had started working as a professional software developer. Although the programming was my hobby since the early years, my skill started to grow when I had taken a real job.

I was surprised when I had recalled my very beginning because I noticed how much I had changed and how big progress I had taken. So, I decided to write it down.

In this article, I’ll take you on a short journey where I’ll tell you about my development process. You’ll find out what I’ve been thinking about, what I’ve been working on and ultimately what changed from my perspective. Ready?

Read more →

Automatic file versioning after change using fswatch and git

I create a lot of notes. Seriously, I write tons of notes. Inspired by Getting Things Done method, I treat my mind as a thoughts generator rather than the storage. I capture thoughts, ideas, inspiring quotes, links, and pictures. Mostly using files.

Although I’m on the early stage of creating my custom note-taking solution, I’ve done some work to synchronize notes between devices and versioning them. In this article, I’d like to focus on the latter and I’m going to show you how to set up automatic files versioning.

I’m a software developer so, unsurprisingly, I use git to versioning my notes as well. Instead of manually committing changes, I take advantage of tools like fswatch and launchd to automate this process.

Read more →

How to use final in PHP?

If someone would ask me about my favorite keyword in PHP, I would certainly answer: final. It doesn’t mean I write this modifier in each class or method. It not only shows the intention but also provides a mechanism to protect the code. At least from the assumption.

The final keyword can be used both on the class level and on the method level. It prevents future extension of functionalities in a non-effective way. If a class is marked as final, then we can’t inherit from it. If a method is marked as final, we can’t override it.

The theory sounds good. Let’s go to details.

Read more →

The practical difference between “findBy” and “getBy” in repositories

Repositories are a special example of a class. They usually have a lot of methods designed to retrieve data from the database or the other storage. To mark this operation in the name of the method, we can use one of the common words: find, get, search. Are all them mean the same? In this article, I would like to show you a practical difference between getById and findById methods.

Read more →

Quick start with TDD in JavaScript using Jest

JavaScript is one of the most versatile programming languages I know, however, I had a constant problem with the testing. Since I run into TDD, I was looking for something that allows me to build my solutions using this approach. When I had been creating a small project in React, I accidentally discovered Jest.

It surprised me because it hadn’t required any extra configuration. I thought that the configuration was built-in into the create-react-app tool. It turns out that zero-configuration is one of the philosophies behind this tool. I decided to try using it outside the React application. Since this moment, this is a standard tool for my unit tests for the JavaScript.

Let me show how easy work with Jest is.

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 →