Search Here

Custom Search

Sunday, August 19, 2007

How solving ACM problems is helpful to develop quality software

Developing quality software is a big challenge for a software company. A software will be more quality-full if it has less bugs and high performance. But reducing bugs and improving performance is more challenging than developing the software. Here I will try to explain how solving ACM problems can be related to developing software.

When we take part in a programming contest we are given some problems to solve as part of the contest. Suppose we have decided to solve problem 'A' of the problem set. At first we go through the problem description very carefully. This is like understanding of the spec of a software. Then we think deeply and try to find out the algorithm to solve the problem which is like determining and planning the strategy to develop the software. After finding an algorithm to solve the problem we just code it and see whether the given sample input output of the problem is satisfied by our program. This is like developing the software and testing whether our desired output is achieved form the software.But we get upset when we submit the solution to the judge of the contest and get the result like "Wrong Answer" or "Time Limit Exceeded" or "Runtime Error" etc.

But what's wrong with our program?? We got the sample output absolutely correct after feeding the sample input to our program. Is there anything wrong with our code? Hmmm this is like getting bugs of the software. So, we should think deeply now whats wrong with our code. Then after several
modifications and submissions of the code we get the msg "Aceepted" from the judge. It means our code is 100% bugfree :)

Actually to get a program accepted we have to think very deeply and vastly in a realtime contest. While participating in a contest I saw many times that only for a single testcase my program did not get acceptance. Usually this is called special case in the problem solvers community. In a word we can say that who solves ACM problems have to think in a vast view about a problem and this fact helps him in a real-life software development. While developing a software if a programmer thinks in a very clever way about the requirements and different types of bugs may occur or any kind of security issues of the software then the software will be more bugless. And to improve performance of a software the underlying algorithm should be improved and most of the ACM problem solvers are conscious about improving performance of their algorithm which can be related to improving performance of a software.

Actually solving problems improve the vastness of thinking of a programmer. It gives a new dimension to his programming skill.

So far I have seen giant companies like Microsoft,Google hire ACM world finalists most of the time even before the completion of their graduation. But why? Because they know to develop a quality software of innovative idea ACM programmers are the best choice.

But there is a little bit problem with most of the ACM programmers. Throughout their student life they only learn C/C++ or at best Java and I observed they feel very less interest about professional software development. They only like to solve problems. If you ask them whats your favorite language they will reply you "C/C++". But if we grab these programmers and train them with professional software development tools and tactics then definitely we can build better software.

Generating Excel using POI in Java

May be you know excel files can be generated from Java by using an API POI.
( to know about POI visit )

When I was using POI to generate excel file I saw a little problem after opening the generated excel file. Suppose I have to display the following text in a cell.

User name: John
Title : Programmer

You see there is a line break between the two lines. That means you have to write “\n” in the code. But when I opened the generated excel I found the two lines were displayed in a single line and there is a garbage box like [] in place of the new line.

But I expected two lines . So what the mistake I did? Can you guess?

Oh shit! I didn’t set the WrapText property of the cellStyle of the Cell.

So, keep in mind to write this

(if the name of the cellStyle of the cell is ’style’.) if your text contains multiple lines.

One more point I observed this problem in MS Office , not in Linux’s Open Office. :-)

Friday, August 17, 2007

An interesting bug of DataGrid of .NET

When I was working at Uniqa S&S Ltd. I got a very interesting bug of .NET datagrid.
Suppose you have bound a Dataview to a Datagrid, then what do u expect?
You expect that the changes that you make to ur DataView will be reflected to the DataGrid immediately. But sometimes it doesn't and it will really make u tensed. But how?? Ok, let me expalin.
To bind a DataView to a DataGrid you just write the following lines of code.
DataGrid dg;
DataView dv;
dg.DataSource = dv;
But sometimes when insert rows in the DataView or make any changes you don't see the reflection in the DataGrid. But when this scenario occurs?
I observed this happens when you bind more than a ComboBox or a DateTimePicker with any column of the DataView's Table.
But I found a solution of this disgusting problem.
Just write following lines after making change to the DataView.
dg.DataSource = null;
dg.DataSource = dv
Then you will see the reflection immediately.

But this is a funny solution. Because the DataSource of the dg was dv from the very beginning and still it is. But to get the reflection you have to change the datasource of the dg and again assign to ur dv. Null is a better choice here.

And the interesting fact is that MS hasn't solve this bug yet in .NET2.0
DataGridView of .NET2.0 has still the same problem.
(Note: I observed this phenomena in desktop development and I am not sure about Web)

Monday, August 6, 2007

Autocomplete mode of ComboBox in .NET2.0

Today I wanna discuss about a new feature of .NET2.0 that was not in .NET1.1
Many times we need the users of a software to give the facility of auto completion and prompting of text when writing.
In .NET2.0 ComboBox and TextBox has the facility.
Just set the Autocomplete property to any of the following
And the Autocomplete DataSource to any one of the following

Then you will see the effect after running the application.
But there is not a facility that Microsoft did not provide. There is no option to provide the Font of the ListItems that is prompted when autocomplete is in action. But this is really very important. Hope MS will provide this facility in the next updates.