Polymorphism in Ruby

Polymorphism comes form the greek words ‘polys’ meaning much or many and ‘morphe’ meaning form or shape. In programming, it refers to the ability to use functions or methods in different ways for different objects or data types.

Having the ability to use the same method in a different way depending on data input is very useful in Ruby. It greatly decreases the need for long, ugly if statements like this: Continue reading

How to Test Ruby IO

Receiving input from a user, doing something with that input, and then displaying some output is core to software development after QA services that help you check your software. This input and output is reffered to as IO.

In TDD, we should test the behavior of all the code we write, but testing IO can be challenging because we don’t want to be prompted for input or have miscellaneous text printed in the terminal while running our tests. I’m going to walk through a scenario where we have a UI class (i.e., user interface) in Ruby that handles all of the IO and explain how to test it. We’re also going to look at the IO class and its STDIN and STDOUT constants. Continue reading

Self & Metaclasses in Ruby

Self has confused me for a while now so I decided to get to the bottom of the purpose and meaning of self.


  • At any point in your program, there is one and only one self
  • Self is the current object accesible to you
  • It can also be said that Self is the receiver object of the current method (ex: String is the object in String.send(:”length”))
  • Since objects in Ruby are usually instances of classes, self is usually the class you are in at any moment
  • Using self enables you to call a method on a class (like Person), instead of just one instance of a class (like Laura)
  • There are a couple different ways to call methods on self: ‘self.some_method’ OR ‘class << self’ before a group of methods
  • You might want to use self if you want to call a method on any potential instance of that object (every Person is born on planet earth but not every Person is named Laura), especially if you don’t plan on having more than one instance of an object (maybe you’re creating a game with one Person, one Fish, and one Monkey–I’m not sure why you would do that–and you don’t want to create multiple instances of Person).

Okay, now for the longer explanation. Continue reading

Server speed for hosting

Its important not only to know the reputation of the web hosting service, but also how fast their server is. Sometimes the speed of the servers itself does not matter, but the speed of their communication can make a huge difference to the speed of your website, since there are different types of hosting with some companies offering dedicated servers to host business websites, so they are more secure, fast and reliable. So do a quick comparison of server speed and site speed for two popular web hosting services and you should be able to see which one offers a better experience.

Here are some important server speed information that we would recommend you to look for:

First, we need to point out the fact that these bandwidth comparisons may not reflect the actual bandwidth used by the customer. Depending on the website you use, there could be some situations when the customer may use many GB of bandwidth at once, for example, because the server is overloaded during a massive data transfer from an outside source. In this case, the actual actual bandwidth used by the customer should also be compared.

Secondly, the speed of the server should also be compared. This way you will be able to see if you can increase the performance of your website with their service. The chart below gives a good overview of the good and the bad speed of a couple of web hosting services.

Relative Website Speed in Mbps

Firstly, lets define website speed in several categories. We will use the following three domains:




In the next table you can see how the bandwidth performance of these different web hosting providers varies. Which is different for each site, depending of the quantity of traffic they get, of course they can also get more traffic and clients if they use marketing services such as Victorious SEO, which specialize in this area.

So it seems that most of the web hosting services are very similar, but we also noticed that we could find some differences. Lets find out more by comparing each web hosting service.

Web Hosting Services Comparison Table

Speed in 5 second intervals

In the previous comparison we found out that in the middle of the internet the speed of a website changes more often than the speed of the server. What this means is that from a normal request, the server has to wait a little bit before it can deliver a response. If we want to take the average performance of a server for a minute, the amount of time the server has to wait is one second, not five. Now we can conclude that the speed of a server does change.

The picture of the speed of a server is the same for every bandwidth test we performed. This means that in most cases the faster the network speed is, the faster the website speed. That means the faster your website will be, the faster your site will load.

The graph below shows the difference between the speed of a network connection and the speed of a server. The higher the figure, the slower the network connection will be.

The second place goes to most of the major servers around the world. The single best option is the datacenter of a major corporation. What this means is that the faster the server is, the quicker your website will load. These companies probably can afford it. You should pay attention to the speed of your server because if your website will be running a lot of visitors from other countries, the server speed might be a problem.