A few days ago, I released a stip-code library and two plugins (for Vite and for Webpack) that use it. Some people might wonder why someone would even want to use them. Other people might point out that there are plenty of similar solutions. Fair enough, however, I didn’t find a good one and had to write my own.
Some concepts are hard to grasp because of lots of details or because the level of abstraction is too high. Recently, I was asked about the Open-Close principle and how I would explain it. It seems to me, that the simplest explanation is when you show it on the micro level example.
Sometimes, the checks in code are so complex, that we have to write very sophisticated conditionals that have lots of conditional expressions. One might say that this is a bad practice. Maybe - but in some cases this is an inevitable evil. The main question is to format it.
Recently, on one of Discord servers an example of how to reverse a string in PHP was posted. Because the example was presented as a production code example, let's take a look and discuss it. Looking ahead, that wasn’t the best example.