Getting wise or getting old
Earlier I used to take pride in myself being able to take quick and fast decisions that were also the correct. This was the case about choosing the the school I went to, the career to start, in switching careers and also moving between jobs.
After 3.5 yrs at HP, I am moving to a new job. Strangely this was something I should have decided about quite easily. Because of circumstances that I won’t mention here, this move is the right decision but still I have spent more time mulling over it that I am myself surprised. For the first time I find myself thinking about a whole lot of things that wouldn’t have even occured to me previously. Don’t know if this means I am getting wise or just old
.
Bitwise 2008
Bitwise 2008, the annual programming contest held by IIT-K is over. I got 58th rank. Better than previous attempts, but way to go:
2006 – No rank
2007 – 623
2008 – 58
Making sure to handle all exceptions
Usually if a library or a low level function throws an exception, there is a good possibility that it is handled somewhere. However if a GUI function (e.g. clicking a button) has an un-handled exception then the application goes down (crashes). In debug mode the debugger would point out the error but in release mode – the application plainly crashes, on the user’s desktop.
For GUI apps, this can be a concern.
Languages like Java are strict in this case. If a method declares that it can throw an exception, all the callers of the method are enforced to implement an exception handler. Code simply does not compile without handling the exceptions.
In .net you can do two things:
1. read the documentation and find out what kind of exceptions can be thrown. For example if you see the penbox library, every method does list the type of exceptions that can be thrown.
2. blindly add a handler for the “Exception” class – generic type and handles ‘any’ exception.
Approach # 2 is easy to implement. However it is not really a good practice. Exceptions should be really used in case of exception – something you do not expect to happen. Adding a common type of handler has the risk of losing valuable debug information. The exception might have pointed out a logic error (e.g. FormatException in converting strings to numbers). Using the appropriate handler, you can identify such cases during debug and fix the code. Using a generic type handler usually means that you are going to lose this information.
Approach# 1 is really good. However it can be a pain to read the documentation.
There is a new tool called “ExceptionHunter” from RedGate. It goes through your .net assemblies (exe or dll) and identifies what all places you have un-handled exceptions. There is a 15-day free evaluation if you want to check out.
Wish you a happy new year
To all my non-existant readers
Wish you a very happy new year 2008.
Sesh
C# – Another “finally” trivia
If a function implementation has a try – catch block with a finally clause, then the finally code block is executed in all cases before exiting the function.
For example, in the following case:
int Foo()
{
try
{
//do stuff here
if(something_happened == true)
return;
//do something else
}
catch(Exception)
{
}
finally
{
MessageBox.Show("exiting method")
}
}
In the above function, even if the function exits at the first ‘if’ condition, the message will still be displayed.
Home Theater Guide – 1
Couple of months back when I started off to buy my home theater setup, I was awestruck with the number of options available. I was especially bothered about spending a chunk of $$ only to realize I missed something or if some better/ cheaper alternative was available to what I brought. So I did my digging…this post is a kind of Home theater 101 based on what I found from my self learning. Coincidentally this also started my audiophile hobby so most of the post will be biased towards that.
Components of a Home theater
Keeping aside the TV, the following are the components of any HT system:
1. Audio/ Video source – DVD or CD player
2. Receiver
3. Speaker setup
A good home theater system will take your movie watching experience to a whole new level. This could be either a life like dialog delivery or a 3D sound environment that makes you think you are part of the movie. The different components of a HT system work towards this:
1. DVD or CD player – read the disc and send the audio + video signals to the receiver
2. Receiver – receiver comes in between your DVD player and the TV/ Speaker systems. It receives the signals from the source (DVD player) and distributes the signals to various units. Eg. video goes to the TV, sound is distribued across the speakers.
3. Speakers – reproduce the sound sent by the receiver
In order to create a life like audio environment, the HT setup distributes sound in 360 deg around the viewer. This is accomplised by the placement of the speakers. In a 5.1 setup, there will be 5 speakers that are placed around the viewer thus giving a realistic experience.
A “5.1″ setup means there are 5 speakers and 1 sub woofer. Other popular setups are a 2.1 – stereo setup or the new 7.1 hidef setup. In these, there are 2 and 7 main speakers accompanied by a subwoofer.
Types of Speakers
One can broadly classify them into the main speakers and the sub-woofer. Different types of sound (instrumental, vocal, birds, animals, vehicles, music etc) fall in different frequency range. The sub woofer is used to play the sounds in the low frequency range (< 100 Hz) and the main speakers play the frequencies above this. The actual value of this cut-off frequency changes from system to system and also based on user preferance. It is called the “cross-over” frequency. Based on your preference you can set the value of cross over as 80, 100 Hz etc .
As discussed above 5.1 means that there are 5 main speakers and 1 sub woofer.
Of the 5 main speakers, each speaker serves a special purpose. The receiver actually splits the sound from the DVD and sends different parts the different speakers. The vocals (dialogues etc) go to the central channel. Then the sound is distributed over the rest of the speakers. This enables effects like sound fading when subject goes out of screen etc.
So how to choose a HT system?
Whether you buy a cheap 200-300$ setup or a 15000$ both are going to have the same components listed above. What makes difference is the quality of sound reproduction – the elite ones reproduce sound the closes to the natural source. This is because they are able to accurately reproduce sounds of different frequencies. So sound quality of the speakers is the number one criteria for selecting a HT setup.
The second criteria is your DVD/ CD player. This player should be able to support multiple formats (CD audio, Apple, Mp3, WMA). One important thing is that it should support the latest Video and Audio formats – HD DVD, Blue-ray, Super Audio CD (SACD). There is a huge variety of players from 50$ to 3000$ to choose from.
The third criteria is the receiever. First it should be able to support a 5.1 setup atleast. Then it should have the required ports – HDMI, S-Video, component etc. Again based on the quality there are receivers available from 200$ to 8000$ and more.
The fourth criteria should be ease of setup. High end speakers usually need special placement to deliver the best sound quality.
When selecting a HT system the first three criteria should dictate what setup you choose. The ease of setup need not really be a deciding factor. Of course you would start with a budget so that really might be the deciding factor on what you end up buying. But within a given budget, it is generally a good idea to spend 50-60% on the speakers and the rest on the player+receiver.
In the next post I will go through some famous brands/ setups available.
Bitwise2007: Programming contest @ IIT Kharagpur
IIT Kharagpur has declared the date for the Bitwise2007. It is on Feb 11th, 2007. More details can be found at http://www.bitwise.iitkgp.ernet.in/index.php?q=home.
Bitwise is an annual programming contest open to all (students and professionals) and has been running since 2001. Last year there were more than 2500 participants! this will be my second year. Lets see.
For the movie buffs like me
Movies to be released in December (and not to be missed)
1. Rocky Balboa (this is going to be huge. the trailers rock!)
2. SpiderMan 3
3. Pursuit of happiness
Sesh
Model based testing
What is the best way to test software?
Delivering quality code and keeping customers happy is the ultimate goal for any software development effort. Common problems people complain about software are that it does not do what they expect it to. Lot of times, particularly in R&D environments the specs are not clear and there are 2-3 iterations before the customers and developers agree that they have a working solution. While ambiguous specs do lead to some kind of re-work, in my personal experience developers do spend time fixing issues reported by the customer. Instead of adding new features, time is spent on fixing bugs in a previous release. If most of the bugs were to be found before the release, there is a good chance of project success as the customers get a stable ‘working’ build.
Software testing plays an important role in ensuring that the application released to customers does what it is supposed to do and without any errors. The definition for testing that I like most is “software testing is running the code in a controlled environment with the intent of finding errors”. Automated testing has come a long way in ensuring that a software product is tested consistently through its various releases. Through automated testing it is possible to excercise so many scenarios that are impossible to be executed manually within a limtied time and with limited resources.
Helpful as it is, traditional automated testing suffers from the pesticide paradox. Just like how a pesticide can kill only a particular type of pests and how useless it becomes once those bugs have been killed, the throughput from automated testing drops drastically over time. Automated tests are still good for smoke tests and regression testing where you are interested to find if some core functionality is working or if old functionality remained unbroken.
However one of the bigger challenges for product release is to extensively test the software. All the functionalities have to be tested, all the code in the application has to be excercised with various inputs to ensure that the program behavior is verified in all its possible states.
This verification of program behavior in all its possible states is quite difficult with traditional testing techniques.
Here comes Model Based Testing.
In model based testing, a behavior model of the software is constructed that describes all the possible functionalities of the system and the manner in which the software system transitions from one state to another. A typical tool used to represent such behavior models are the finite state machines.
A typical model based testing framework consists of (or is developed as):
1. Create or define a model of the system under test. Examples of models are state transition table or the finite state machines.
2. A separate component then uses the model to generate test cases. From the state transition table or the FSM a directed graph can be built with the different states of the system as nodes and the transitions as the edges. Using graph traversal techniques it is possible to determine a sequence of input actions that leads the software to a particular state. The sequence of input actions form the test case and the final state is the excpected result.
3. As the software evolves, only the model needs to be updated with any new states and transitions. The test suite can then be updated automatically. Another advantage of this methodology is that the expected behavior (test oracle) is also built into the scheme.
An excellent and comprehensive reference to MBT is available at www.model-based-testing.org and www.geocities.com/harry_robinson_testing. This is maintained by Googler Harry Robinson.
In future posts, I will share examples of creating behavior models and also blog about creating a model based testing framework.

