“Before you speak, listen. Before you write, think. Before you spend, earn. Before you invest, investigate. Before you criticize, wait. Before you pray, forgive. Before you quit, try. Before you retire, save. Before you die, give.”

Friday, September 17, 2010

The challenge

Here I am facing a new challenge : Getting admitted into the masters program at the university.
It's a Master in Artificial Intelligence which is a field I am interested in but it is not very easy to get in.
You have to pass an exam containing subjects from
1) Algorithms analysis and design -using the famous CLRS book ("Introduction to Algorithms")
2) Databases
3) Object oriented programming - mainly SCJP like questions
4) Subject of choice from 4 other fields - I chose AI here and the AIMA book.

I started reading the AIMA book and the CLRS book but it looks like the mathemathics involved is overwhelming ... I never was a math genius.

This situation raised a lot of mental blocks for me and considering that Monday I have to take the exam it looks like I am heading for a complete disaster.
But it never hurts to try. I need to get admitted on a 1 1/2 candidates/position situation , all things considered it is a lot better then some interviews I attended .

Also I realize that although I have a B.Sc. in Computer Science and Electrjcal Engineering I never used a lot of the knowledge from the university .. maybe this is a industry problem , maybe I am trying to learn astronomy when I am they guy that fixes telescopes.
Writing good programs involves knowing things like complexity , knowing if a problem is NP-complete and stuff like that .. but most of the times you can just call an external library that already figured this stuff for you .. so you don't have to.
Just for fun I wrote some Java code that performs a merge sort and another performing insertion sort and tried to enter 10.000.000 long array.
The difference was amazing. Even on my core I7 860 processor using it's 8 cores (4 physical and HT) it took 1252 seconds to do the insertion sort and about 159 seconds for the merge sort.
On the other hand most algorithms offered by programming languages are fast enough so I rarely was in a position where I needed to evaluate the algorithms.
So a part of me is wondering : shouldn't I worry about more important stuff then about this albeit important ,pretty much useless in real world enterprise development , but the part of me willling to learn new stuff supports this idea.
Now I need to get back to work and hopefully not be the last on the exam.
LE : If I fail I have the "excuse" that I studied for my SCEA certification and had not time for this exam , and I did not study algorithms design at the university .. and I am lazy :).
LLE : As expected I got a bad mark (6.91) qualifying me for the "tax" part of Artificial Intelligence. Since I am not eager to pay 1100 Euro to study AI I guess I can wait another year in which I can sort other issues in my life.
Anyway my view is that the exam was totally doable and thinking positive would have helped. No harm done anyway.

Thursday, September 2, 2010

Automating functional testing

So here is the drill : You need to wear the testing hat and verify the bugs .
You need to test a huge application and see if some bugs are reproduced.
Typically each bug requires about 3 page navigation and 20 clicks and you need to be able to reproduce it without issues and show it to a co-worker.
My attention span in the open plan office is not that big .. I always click some button I shouldn't have clicked and then have to start all over. Anyway bugs need to be fixed and issues need to be found. You also need to find new bugs and regressions.
Here is the solution: Automate functional testing.
What I used so far and can fully recommend:
1)Selenium IDE - first step is to record the tests and generate the required Java/Ruby Code
2) Use Selenium Java (or Ruby) driver and write the tests in the IDE
3) Start Selenium Server.
4) Run Selenium code from the IDE ( or a C.I. machine like Hudson,CruiseControl)

Here is how I test a simple login , search and logout(Ruby version) :

require "test/unit"
require "rubygems"
gem "selenium-client"
require "selenium/client"

class WorldFredomTest < verification_errors =" []" selenium =" Selenium::Client::Driver.new" host =""> "localhost",
:port => 4444,
:browser => "*chrome",
:url => "http://localhost:8080/",
:timeout_in_second => 60


def teardown
assert_equal [], @verification_errors

def test_login
@selenium.open "/WorldFreedom-war/mainPanel.htm"
@selenium.type "j_username","mihai"
@selenium.type "j_password","freewilly"

@selenium.click "login_button"
@selenium.wait_for_page_to_load "5000"

@selenium.click "searchFreedomsTab_lbl"
@selenium.click "j_id102:searchButton"
@selenium.wait_for_page_to_load "5000"
@selenium.click "logout"


Of course no warranty is provided for the code above. It just works on my PC.
Coding the functional tests should be done by a functional testing team (no connection to the actual development team) and bugs should be reproduced by means of running these tests.
Of course in an agile environment these tests are also used as acceptance tests.
Setting the speed of the tests is also good since making them run too fast will reveal performance problems with the application.

There is a catch here : No test will ever catch a cosmetic bug , a colour which is wrongly used or a table that is creating a horizontal scrollbar. You need a human for that .. and that human tester will be required for the foreseeable future.