Fernando's Blog

Welcome to my blog !


Configure Sidekiq With Rails

Published at November 23, 2020 ·  4 min read

According to their website Sidekiq is an efficient background processing for Ruby. It says Ruby but you can also use it in Rails and it even has a nice web UI where you can see some stats. This blog post will be a brief overview of how to configure Sidekiq in Rails. The very first thing is to add the gem in the Gemfile like this gem 'sidekiq', '~> 6.1.0' and run bundle install...

Minitest Custom Assertions

Published at November 19, 2020 ·  4 min read

Since I discovered the world of testing and TDD I’ve loved the philosophy behind it and the safety net that it brings. My first interaction with testing was with Ruby on Rails specifically with RSpec, but I’ll admit it, understanding and getting used to testing is not easy but RSpec did a very good job at making it easier and in combination with shoulda matchers makes tests wonderfully easy to read....

Software Design Patterns (Builder)

Published at August 11, 2020 ·  3 min read

The seventh and last blog post in the series of Software Design Patterns it’s an interesting one, it’s the Builder Pattern. The builder patter is a unique pattern that allows us to create complex objects out of several simple and independent objects. A key advantage of this pattern is that it creates a clear separation of concerns and a better control over the object that we’re creating. Here’s an example built in Python:...

Software Design Patterns (Strategy)

Published at August 3, 2020 ·  2 min read

In the sixth installment of the Software Design Patterns blog series I’ll talk about the Strategy Pattern. This pattern is interesting because it allows the consumer of this code to choose what “strategy” it wants to use to do the work that needs to be done. You could have a list of different algorithms that are interchangeable and depending on the need we can choose one or the other. You can use this pattern in conjunction with the Adapter Pattern....

Refactor a Never Ending 'if' Statements Into a Rule System

Published at July 26, 2020 ·  7 min read

This comes from a personal experience while working on a big refactor of an Ad Server, in an ad serving system you have creatives, campaigns, ad units, templates, etc. On the client side, meaning the website that will server the Ad it serves the creative code that will ultimately calls the Ad Server requesting an Ad by sending the Creative ID, along with the client information coming from the HTTP request....

Software Design Patterns (Adapter)

Published at July 25, 2020 ·  3 min read

In this fifth part of the Software Design Patterns blog series I’ll talk about a pattern that probably most of us have heard of or even used before but that we haven’t had the opportunity to build, I’m talking about the Adapter Pattern. The Adapter pattern acts as a bridge between two incompatible classes by “adapting” the functionality of one class into the other via an interface. One of the most popular examples of the Adapter Pattern is how different programming languages uses Adapter classes to access a database, it’s very common to se MySqlDataAdapter, PgSqlDataAdapter, etc, what these adapters are doing is creating a bridge or “adapting” into the specificities of each database engine so you don’t have to worry about those minor details or worse having to create your own adapters....

Software Design Patterns (State)

Published at July 25, 2020 ·  3 min read

This is the fourth part of the Software Design Patterns blog post series, in this post I’m going to talk about the State Pattern or the State Machine Pattern, which is a pattern that defines a way to transition between the state of a process and allows you to define the rules of the transition. I’ll explain it with an analogy of the state of a computer. class ComputerState(object): name = "state" allowed = [] def switch(self, state): # Switch to new state if state....

Software Design Patterns (Observer)

Published at July 25, 2020 ·  2 min read

This the third part of the Software Design Patterns series, in this post I’m going to talk about the Observer Pattern. This pattern is not exactly the same as the Publisher/Subscriber pattern but is very similar in the way that we have a publisher instance that publishes messages and we also have subscribers that are subscribed to the publisher’s messages. This pattern can be really useful because we could build a workflow where we can have the Publisher publish to the subscribers that an image have been downloaded and then have the subscribers transform that image into multiple formats....

Software Design Patterns (Factory)

Published at July 25, 2020 ·  2 min read

In this next post from the Software Design Patterns I’ll talk about one of my favorite patterns which is the Factory pattern, this pattern allows you to create objects without exposing the class directly or its functionality and you interact with the object through a common behavior called an interface. This pattern is great because it reduces complexity when you need to instantiate objects which have the same behavior so you can focus the business side of the application....

Software Design Patterns (Singleton)

Published at July 24, 2020 ·  2 min read

Software patterns for me is one of the most exciting practices in software engineering, it encapsulate best practices that have been been “discovered” and/or created along the years of people writing software, this is going to be the start of a series of posts where I’m going to talk about some of the patterns that I find very useful. Singleton This defines a pattern for when you only need to create a single instance of a class for example let’s say you have a class that is heavy on the initialization or that the class belongs to a service that you are creating that you need to maintain either state or share the state between other sections of your app, it could even be a class that calls a third party service that you don’t want to be initializing every time that you need to call some function on it....