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

The importance of using the right data structure

Have you ever read The Algorithm Design Manual? No? Well, I’m not saying you should, but it might be useful and it wouldn’t hurt. The name might give you a hint about its content, but for me, it’s the way this content is explained that makes this book great. I think the way the author presents its' concepts, giving real-life examples, makes all the difference. And of course, the famous Catalog of Algorithmic Problems is an invaluable resource....

November 14, 2013

Python decorators

In Python, functions are first-class objects. This only means that, like everything else, they’re objects. That can be a handy feature because that way we can pass functions as arguments to other functions. And also we can use functions as return values of other functions. Confusing, uh? Let’s see that with an example. def receiver(new_func): new_func() def return_function(): def func_to_return(): print "I was returned" return func_to_return receiver(func_received) func_returned = return_function() func_returned() If we run this, without any surprise we get:...

November 7, 2013