Day: April 16, 2008

Why do I Test?

Most of you who would read this would have done some level of testing in their programming career. Many of you would appreciate the fact that unit testing exists in the world.

Analogy that works for me is that in real life, I test all the time. I test so much that it has become a habit so much so, that I now do not even realize that I am testing. If I think about it, I can site many examples. The reason I test so often is because I want to be sure that things will work when I need them to.

When I became a programmer, I found myself doing that same just out of habit of testing everything. Since I started to code, I have come across may programmers who have reasons not to test and they resist testing al their life. Once they find themselves in a the arena of no testing, they enjoy and as per them are most productive. As for me, there have been times, when I have not tested myself, and I have been productive as well, but I have always found that the applications that I design/code with writing tests end up being prototypes.

I see many benefits of testing, and thats the reason when I start a project, I make sure that the first thing that is done is to setup an integrated unit testing tool for me to write my tests. In other words, without unit tests, I do not trust my own code and I would not even go into changing it – I can never know after a few changes if I broke something. Unit tests act as an umbrella that saves you from a downpour for defects in the application.

Passing my code along to a new developer has been a challenge. Ever tried giving a new programmer a code walk through. I tried test walk through and it has been a wonderful experience. They understood the code once and were able to start coding faster. I like to call my tests as API documentation for my code.

I have been unit testing in projects for last 3.5 years now and always I have found in a later stage how valuable those tests were. Coming to Flex, I started to find similar options and Flex Cover was the answer. Simple to get started and now very soon I would have my testing suite for Flex as well.

Eager to hear what your experience have been.

Java to Flex

My clients were talking to me about Flex for 2 months, but one day they came back and announced that we need to move the project to Flex instead of traditional AJAX. And, it was time to get into a new technology.

Leading a team into architecture, when you are unsure of the architecture is a tough task and then when the technology is known to your clients adds to the equation, but little was I aware at that time that Flex would be a simple one to beat like a beginner level for Dungeon Siege, with someone who has the most advanced weapons in his toolkit.

I took off by reading on Flex SDK, Flex Architecture and Flex Builder (installed the trial version for 90 days). Knowing the Eclipse environment was an advantage and I did not have to learn the interface. Quickly I had setup a project and in next few minutes I had the traditional “Hello World” in place. Much like Visual Basic 6. This was cool stuff.

Now was the next challenge – ActionScript 3.0. They say that AS is bsaed on ECMAScript which also is a grandfather for JavaScript. Knowing Java, C# and JavaScript, how different can that be, but yes this time there were difference. AS was more close to Java with strongly typed objects. There is a class for everything and I was unaware of them, apart from what are native datatypes like String, int etc.

Next came Events – hmm. This made me to think for a while, something that all desktop based applications are based upon, yet it was evading me. And for goo reason, I was chose not to read through the Event model for Flex and that was my mistake (do not repeat that one). I started off by reading on the Live docs the Event Model for Flex and once that was understood it was simple one.

I knew the basics now, but this was not good enough to use in an Enterprise Application. Could I use all of this for my website – piece of cake, but that was not what I was trying to do. My clients had recommended the Cairngorm library – light-weight, quick start framework. It was said that this will solve all the problems. Before I started off with Cairngorm, it was time to put my Architect hat on and not listen to anyone. And i found out that Cairngorm had a competitor – PureMVC. So, these two have to be be on top of their game to be of any use – I started investigating, but very soon came to a conclusion that PureMVC would take more time to get going. So, Cairngorm was it; looking at the community backing and also that it comes frm Adobe decision seemed a good one.

Few weeks went well, and then we realized that Application was not looking as Crisp as it should be. If Flex builder was to be used to draw layouts quickly and that is what we were doing, what was wrong? There were fine prints missing and now came the Constraint based layouts. It was worth while looking at all different kinds of layouts and how can they work, before settling on Constraints based.

Where am I today – ready to start building training material for my team on all the items as listed down. I am hunting for some videos, so if you have some, please point them to me or else, I will end up creating a few.