Let’s start with a definition: “a trait is a concept used in object-oriented programming, which represents a set of methods that can be used to extend the functionality of a class” (Wikipedia) So, a set of methods. No properties. No extra state representation. After all, as you may know, this is the fundamental difference between…
Removing code literals
Every software code contains literals (usually numbers, strings, booleans or characters). They are values related to application configuration, parts of the business logic, natural or language constants, etc.. We have learned to replace many of these values with variables, constants or function calls for various reasons (security, manageability, readability, expressivity,…), which we are not going…
Truncating decimals from summands and sum
This is a problem that you may have run into at some point. Especially, if you had to display or print the components of a price using less decimals than the decimals used for the calculations. Cutting-off decimals after the calculation has taken place can lead to inconsistency between the summands and the sum. In…
Design patterns in Action: Flyweight and Enumerated types
Flyweight pattern is not a pattern that you will come across very often in web applications. Most web applications are just serving incoming HTTP requests, a task that lasts just a few milliseconds. So, memory usage is not really a consideration for their developers. However, there is one area where you can see this pattern…
A long cheatsheet for Redis
Setting up Redis: (on Ubuntu 16.04) Install Redis server apt-get install redis-server Enable Redis as service (start on system boot) systemctl enable redis-server.service Note: The service configuration can be found at: /etc/systemd/system/redis.service There you can see that Redis will be running as user redis: User=redis Group=redis The Redis server will always restart after reboot: Restart=always…
Web Frameworks: The Laravel bootstrap process
Every developer who respects himself should, sooner or later, understand the tools he/she is working with work. And frameworks are not an exception. For those who don’t have the time to delve into the Laravel internals, here is a list of the main actions that take place every time Laravel is called (based on version…
Web Frameworks: The Laravel DI container
This is an overview about Laravel’s DI container ( Illuminate\Container\Container ) and its functionality. It is interesting to have a look since the logic behind most of the DI containers is more or less the same (not to be surprised. After all, the goal is the same, too.) (a) It is a singleton. There can…
Agile software development: back to the roots
I am sure that most programmers are nowadays familiar with the term “agile software development”. If it happens that you have experienced some “agile” methodology in a few companies and made a few discussions about this “agile” idea with programmers from other companies, you may have noticed the huge gap that many times exist between…
Design Patterns in Action: Decorator and SPL Iterators in AWS S3
My purpose here is to talk about the decorator pattern in SPL iterators. But since many people are not aware of how much the iterators are really used, I would also like to point out one of their use cases in real life. So, my starting point will be AWS Simple Storage Service (S3). For…
Design Patterns in Action: NodeJS rate limiter and promisification
Disclaimer: Here, I am not going to present some real-life example where promisification is used but I am gonna show you how to apply this pattern in a real-life example. The promisification is a necessity that comes from the asynchronous nature of Javascript whenever we need to make synchronous calls. Let’s assume that we want…
File Permissions: the painful side of Docker
The source of all evil: The whole issue with file permissions in docker containers comes from the fact that the Docker host shares file permissions with containers (at least, in Linux). Let me remind you here that file permissions on bind mounts are shared between the host and the containers (of course, there are also…
GraphQL: an offspring with good genes
GraphQL, as most new programming techniques (or styles or libraries), is trying for the last couple of years to find its place into the world of software development. The problem arises when people try to evaluate new techniques without taking into account the past of the relevant technological sector. Even when a new technique really…