Quicksort

Quicksort is a popular sorting algorithm. That being the case makes sense that we see how to implement it right? Let’s go then. This algorithm basis itself on divide-and-conquer. For our purposes what that means is that, at each step we will use a pivot and divide our list into two sublists: one with lower values and one with equal or bigger values. Then we sort each sublist. The stopping condition of our algorithm will be when we reach the empty list....

January 28, 2014

Test your code with unit tests

You have a piece of code and you want/need to test it. Let’s get on with it! We will use a previous post as the code to test (you can find it here: Design Patterns: Factory Method) and will make use of Python’s unit testing framework (unittest) to build our tests. Let’s not get ahead of ourselves. First, a common testing practice: to test their code many developers write some function that makes use of it and check if it works properly....

January 16, 2014

Design Patterns - Factory Method

Design Patterns is an important subject to any developer and so you can expect a post about them every once in a while. The Factory Method is an object-oriented creational design pattern that deals with the problem of creating objects without having to specify the exact class of object that should be created. Let’s build a simple example to illustrate the concept. We’ll create a class that will deal with names....

January 9, 2014

Integration Testing with PageController

I believe that testing is a crucial part of software development. Some might argue that it’s not that important, but I think it is. But, that’s a discussion for another time. If you’re still reading, it means that the previous paragraph didn’t throw your attention to other tabs in your browser. Good! Let’s dive right in and check out what is this PageController thing. Unit testing, again in my opinion, is a fundamental practice to any software development process....

December 7, 2013

String Searching Algorithm

There are always those situations, when all of us are faced with the problem of finding a substring inside a string, or string in a text, or a set of pattern strings on a text (whatever flavour you like). Being this a common “problem” chances are your language of choice already has a very good implementation that you can use. But, it might be the case, that you really have to implement it yourself or you just want to understand how such a thing might work....

November 21, 2013