Crash early

A dead program normally does a lot less damage than a crippled one.

The Pragmatic Programmer, Tip #38, page 113

Have you ever thought about what can go wrong when the application’s logic is broken, but it continues to work? That might happen when the values are not the ones that you expect. For example, a method/function returns an integer, but a negative one, but you expect it to be positive. Another example is trying to access an unknown array key. The database returns an invalid value. You name it.

What if you won’t allow it and crash early? Yes, the client will see “an error occurred, our engineers are working on it”. The actual benefit is that the program will exit and not cause any harm. No corrupted data in the database nor missing files.

How to crash early in the PHP? There are two ways. Throwing a \LogicExpcetion or enabling assertions on production and using them.

Continue reading Crash early

Symfony & PSR-16 Simple Cache

This week I was working on the integration with the Optimizely Feature Toggles.

Its PHP SDK is mediocre.

It makes the HTTP request for the data file whenever the new PHP process is executed.

The data file is in our case larger than 2 MB, so it has to download a large file, but also validate it and parse it.

That makes around 700 ms overhead on each process.

Therefore I needed a cache mechanism.

But, as we try to write the software in a framework-agnostic way, I wanted to use the industry standard interface – the PSR-16 Simple Cache, to not be coupled to a specific cache implementation.

Continue reading Symfony & PSR-16 Simple Cache

How to stay focused in the work?

During the last weeks, I started experimenting a bit with the focus of the work.

Key takeaways:

Split your work into blocks.

The first block should be reading and communication.

You can close your Slack and email after you read all.

Put proper status so your peers will know that you are in the zone.

Do not sit too long in the zone, use the Pomodoro technique to do breaks often.

Close the focus block and then take a break for reading and communication.

Spotify can be your friend and also an enemy, the song which you do not like at the moment can distract you.

As a replacement, I can recommend which has a built-in Pomodoro timer.

Put your phone in a different room, and use the focus mode on your Apple Watch and MacBook to keep focus.

Sleeping – what I have learned

Time for a new episode of what I have learned! 🎬

Wanna be better? Sleep more 💤 During the last few years, I discovered that sleeping eight hours works best for me.
Focused more and much more productive I am 💪
I have tried sleeping less than six hours plus naps. It worked well till I missed the nap. Waking up was hard 😓
Monitoring your sleep is vital. Many researchers say that it is easiest to wake up in the REM, and I can confirm that ✅
That is why I switched recently from 7.5 to 8 hours. I missed the zone.
Now I can wake up and almost instantly jump into the action.

Sleep well 🙂

YAML anchors & aliases

Hey! Last week I was focused on moving the API specification from slatedocs to OpenAPI. This was the first that I had the pleasure of writing a schema by hand, before that I always generated it. I learned a lot and I would like to share one thing.

By default the OpenAPI allows you to define a schema for reusability. But there is one more thing that you can do for reusability – YAML anchors and aliases. By using it you can reuse much more than just a schema:

Continue reading YAML anchors & aliases

Learning mindfulnes

Howdy, some time has passed since I wrote the last message 👋

I was enjoying the #vacations, but, also learning something new 🎁

The thing that I was #learning/enjoying is #mindfulness 🧘🏻‍♂️

This is a technique which always you to take control of your thoughts 🧠

There are many situations where your thoughts are distracting you or prevent the #focus 🤯


When you have finished the working day, but your brain still is there, thinking about that task you did not finish 😑

You had an intensive block of focus work, you were coding for a few hours. But now you have a meeting, but somehow your head is not listening. Your mind is still in the #zone 👨🏻‍💻

Or you are still stressed after the presentation you just did 😬

But, how to do it?

Continue reading Learning mindfulnes

Improving the tests with try-finally block

This week I have learned a neat trick that you can apply to your test cases. You are testing an edge case. The system under test is expected to throw an exception. But, after the exception, you need to do a few assertions. Usually, I did it this way:

 * @dataProvider markAsUndeliverableFailDataProvider
public function testMarkAsUndeliverableFail(Order $order): void
    $exception = null;

    try {
    } catch (\Throwable $exception) {

    self::assertInstanceOf(OrderStatusChangeFailed::class, $exception);

But, there is a better way to do it! Check out the much more readable version with try-finally:

 * @dataProvider markAsUndeliverableFailDataProvider
public function testMarkAsUndeliverableFail(Order $order): void

    try {
    } finally {

Viola! Look how clean this is 🔥

Sytuacja w IT a COVID – przemyślenia

Cześć! Żyjemy już dość długo w świecie pandemicznym. Tym razem opiszę swoje przemyślenia o tym jak COVID wpłynął na branżę IT. W tym wpisie przedstawię moje obserwacje oraz przemyślenia w trzech etapach. Na końcu znajdziesz podsumowanie, gdzie subiektywnie podsumowuję całość.

Świat IT przed pandemią

Jeśli pracujesz/pracowałeś w IT to wiesz jak to było. Zdecydowana większość pracodawców nie zgadzała się na pracę zdalna. Czemu? Bo przecież pracownik w domu, zamiast pracować, będzie zajmować się wszystkim, byle nie pracą.

Continue reading Sytuacja w IT a COVID – przemyślenia

Wpływ silence operatora na error reporting w PHP

Hej, w dzisiejszym krótkim wpisie bierzemy na tapet słynny i jakże często używany operator @ tzw. STFU. Czy wiesz że jego użycie ma wpływ na error_reporting w PHP? Weźmy pod lupę ten przykład:

<?php declare(strict_types=1);


    function () {
        // int(0) [PHP <= 7.4]
        // int(4437) [PHP >= 8.0]

// int(32767) [E_ALL]

@trigger_error('warning', E_USER_WARNING);
Continue reading Wpływ silence operatora na error reporting w PHP

Moje dwa lata z Huel – subiektywna recenzja

Hej! Dzisiaj temat kompletnie niezwiązany z programowaniem, czy IT. W kwietniu 2021 minęło dokładnie dwa lata od kiedy pierwszy raz zamówiłem Huel. Produkt, który zmienił moje nawyki żywieniowe, i pozwolił mi prowadzić zdrowszy tryb życia. Postaram się opisać wszystkie swoje spostrzeżenia. Myślę, że przez ponad dwa poznałem produkt dobrze.

Continue reading Moje dwa lata z Huel – subiektywna recenzja