Skip to content

Null Object

Null Object Design Pattern logo

Null Object is a behavioural design pattern based on inheritance which creates a valid representation of null objects in a system, in order to avoid returning null objects, on which respective null checks would be needed to prevent NullPointerException and unexpected behaviour of the application objects.

Introduction

It’s common to write methods that return null in situations where the requested information is not present or some conditions are not met in order to execute some chunk of code. However, sometimes this behaviour is poorly documented so it takes the developers using a given API by surprise, moreover, it can force that said developers to write lots of null checks to avoid runtime exceptions.

On either way, the application code might end up with a lack of cohesion and not clean at all, because now this chunk of code has to deal with a “null possible situation” and take decisions that would not be supposed to be taken by itself.

The Null Object design pattern comes to work on this problem, basically, instead of returning null where an object of class Foo was expected, one could return an object of a subclass of Foo in a basic valid state but at the same time, adhering to Foo‘s contract.

Read More »Null Object

Enable MySQL Remote Access

This tutorial will show how to enable MySQL remote access in order to make it accept connections from the network instead of just local connections.

The Problem

A fresh MySQL installation has its remote access disabled by default for security reasons, however, it can be enabled by taking a few simple steps.
It is important to mention that the following solution was tested against CentOS 7.2, but it’s very likely to work on other Linux versions and/or distributions.
I am going straight to the solution to make your MySQL avaiable for remote access, but you can find a detailed explanation at the end of this post.

Read More »Enable MySQL Remote Access

Builder

Builder Design Pattern Logo

Builder is a creational design pattern which aims on decoupling the construction logic of a complex object from its representation.

Introduction

Sometimes an object construction can be complex, because of parameter validations, search of informations on files or database, or even for numerous parameters the object’s constructor is waiting to receive. If you mix up the logic creational logic along the class’s behaviour logic, you may lose the class’s cohesion and can make it difficult to reuse.

Builder design pattern comes to solve this problem, putting both creational and behavioural logic on it right places, by providing enough encapsulation for object’s construction, in such a way you can even develop any number of different implementations for a single builder.

Read More »Builder

Design Patterns

Design Patterns Logo Image


Design patterns are a collection of abstract solutions to recurrent problems in object-oriented software development. These solutions are presented like templates that can be applied in many situations and programming languages, but with similar structures, providing a design which contributes to system’s flexibility, extensibility, portability and code reuse.

Read More »Design Patterns

Ruby Hello World

Ruby Logo


This guide will show you how to write a Ruby Hello World and get a basic and initial understanding about this programming language.

Why Ruby?

As a Java developer for four years long, I’ve always had the curiosity to learn a new object-oriented programming language. Given a great feedback I had from a job interview I went a few weeks ago, and some research on the international software development scenario, I’ve found out that mastering just one language may not be enough.

Specialists are well recognized at their fields of work on software development (and I seriously intend to become one on Java), but the business dynamism grows it’s requirements every day, consequently, requiring the most versatile professionals.

By the given experiences and observations, and following the path of lots of respected developers on the community along with some personal interest, I decided to finally put some serious time on studying a new language, then Ruby is the chosen one!

I’ve already read a lot about the language, however, I’m going to dedicate this post to a simple Ruby Hello World to not extend it so much.

Read More »Ruby Hello World