Blog posts by Yannick de Lange

Immutability of Data

When dealing with enterprise software, your data is often the most valuable part. It contains all your customer information, contracts, invoices and much more. So what are you going to do to make sure the data is being dealt with correctly? A bug in your code can have a high impact on the integrity of your data. If the bug is causing unwanted changes in your data, fixing the damage might prove to be quite a big challenge.

With this post I would like to show how data immutability can help design a more robust system. One that is less susceptible to bugs that might make unwanted changes to your data.


Creating Bundle Configuration

Iltar wrote an excellent post on what bundles are in Symfony. In this post I will dive a bit deeper into the configuration of a bundle, since most bundles require some configuration to work. Think of the Doctrine bundle that requires you to configure the database connection. Another example is the twig bundle which has a config item to let it know if it is in debug-mode. But how do you write those configs, how do they work, and why should you use them?

In this post I will give an example of what you need to do to create a configuration for your bundle.


Service Decoration in Practice

Recently WouterJ has written an excelent article about repositories and how to treat them as collections. In it he also shows that it is useful to have interfaces on your repository classes. If you have not yet read it, I fully recommend doing so.

This concept is something I have recently applied in a project and found that there are some extra benefits in using those interfaces. In this post I would like to expand on WouterJ's ideas and show how this enables service decoration.


Machine Learning: Naive Bayes

Machine learning is becoming more and more ubiquitous in our daily lives. From thermostats which know when you will be home, to smarter cars and the phone we have in our pocket. It seems like it is everywhere and that makes it an interesting field to explore! But what is machine learning? In general terms, it is a way for a system to learn and make predictions. This can be as simple as predicting relevant shopping items to as complex as a digital assistant.

With this blog post I will try to give an introduction into classification using the Naive Bayes classifier algorithm. It is an easy algorithm to implement while giving decent results. But it will need some statistic knowledge to understand, so bear with me. By the end of it you might see some applications and even try to implement it yourself!


Single Page Application considerations

With the rise in mobile computing power and faster browser the internet has seen some change. Where websites used to be simple pages we now have a rich user experiences and mobile apps. These complex sites are usually called Singe Page Applications (SPA). No longer are sites separate pages like a book but behave more like desktop applications. They can better cater to their target audience because they provide more flexibility. Yet, all this comes at a cost. The question becomes: Is the web better for it?

In this blog post I will try to motivate why you should reconsider when you are thinking of creating an SPA. Not everything should be an SPA and some serious downsides which you need to consider.


Symfony, versioning and compatibility

Versioning is more than just slapping an incremental number on your new release. A good version increase will let the users of your package know more than just a new release. Most of us will understand the difference between major and minor versions. However, using a proper versioning scheme can help people a lot with what the impact of the upgrade will be.

This post will try to give some context to the Symfony versions. What to be aware of with a new release, be it a patch, minor or major version bump.


Using bitwise instead of booleans

The naive way of storing many boolean options (in a database) is to create for each option a field and storing a 0 when it is false and 1 when it is true. Consider the following example, something some of you might have written in some variant.

<?php
class Config
{
    public $option1 = false;
    public $option2 = false;
    public $option3 = false;
    public $option4 = false;
    public $option5 = false;
    // ...
}

$config = new Config();
$config->option1 = true;
$config->option4 = true;
$config->option5 = true;

$object->configure($config);

Which of course works, but adding options will require a new field, which might require creating a compatibility layer for your old data. There is an easier way to do this and it's even more efficient at checking fields.

This brings me to an old topic which I have to explain to all the new people at some point and even once explained not everybody understands how it actually works. So in this post I'm going to explain how to use bitwise operators and how it works internally.


Avoiding static in your code

For anyone not familiar with the static keyword in languages, it is in essence a way of defining things on class level instead of instance level. This allows you to access the same reference from anywhere in your code.

As a new programmer that has been introduced to the static keyword, that might seems very useful. I do not blame you for thinking so, since I did so too not all that long ago. As you write more and more code, you learn and improve and your coding matures. You start to form new ideas as your applications grow bigger and you maintain code that is slowly becoming legacy code. When you look back you will discover that defining things static might make things more difficult than they are worth.


Migrating your project to Symfony

From time to time I see people struggling with trying to port their existing site or web-app to Symfony. Their old framework architecture might not match that of Symfony, making porting their controllers not that easy. Other times, their data structure contained so much logic that it was impossible to simply replace with a new ORM. Thus porting the project can seem like a daunting task.

So, what are your options of migrating to Symfony? Well you could try the 'big bang' approach and just power through your project, porting all of it and then releasing it all at once. While I might not consider this the most optimal way, it does have its advantages. It's gives you a clean slate which allows for a fresh new design and fixing all the legacy stuff you had from the old framework.

But what if your project is too big or you want a more graceful way of migrating? Well there is another way, which allows for a more gradual replacement of the old code. This is running both Symfony and your old project at the same time using a fallback method, and it is a lot easier than you might think.


Bloginception

I think the need to blog for a programmer is something inherent. It's a desire to spread knowledge, and create a post is something everyone can read. So it's a bit strange, at least to me, that there are not more blogging platforms targeted at developers. A quick Google search either results in Wordpress plugins, NodeJS HTML generators or CMS solutions.

This happened more often if I have to believe this twitter post: https://twitter.com/iamdevloper/status/743799765566054410. I think there are more developers which create their own blogging software and then blog about it, like... This post. Then again, it shows that there is no proper solution for software development blogs yet.


Yannick has been working with Symfony since 2013 but he is also developing in other language like java or python. He can usualy be found tinkering with some project.

Copyright © 2016 stovepipe.systems