Mahboob's Journal

Existential Thoughts, Experiential Inferences and Occasional Whacky Connections

Previous Entry Share Next Entry
Associating with CSI

 I have been a subscriber of CSI Communications magazine for the last few years. (Note: CSI = Computer Society of India). My name is on their email list.

In July, I received an email from Prof. I.L. Narasimha Rao, Vice Chairman of their Hyderabad chapter about a session on Qt. The operative phrase that attracted me was the first two words of the topic - "Platform Independent C++ Application using QT4.7". My previous job at FedEx was entirely dealing with C++, and I have been away from it since joining Four Soft in 2004. Platform independence was good enough for me to attend a tech talk.

The presentation was on 24th July at the CSI office opposite Secunderabad railway station. In typical Hyderabadi style, I reached the venue late. How can a Hyderabadi reach a meeting on time? Anyways, the speaker Rajeev Ranjan of Wipro also had his revenge. He was wearing a formal suit with tie but had sports shoes on. We were even. 

Most of the audience was comprised of students. The speaker showed the basic features of Qt and a few example applications. I found very attracted to the fact that the Qt library works for PCs as well as mobile devices. After the session, I wanted to play with Qt and C++.

Sudoku programs is a favourite subject of mine. A couple of years ago, I had translated a few programs written in various languages into C#. Hence it was a natural topic for my C++ re-entry.

Googling showed that a C program to solve Sudokus was available on Steven Skiena's website. Prof. Skiena is the author of the superb book "The Algorithm Design Manual". I started putting his C code into a C++ class in my spare time during evenings and weekends.

Meanwhile, Mr. Narasimha Rao contacted me and inquired if I could conduct a technical session. I agreed, and since the CSI audience is primarily students, I selected rapid JEE development as the subject.

At 4S, my team had developed an internal tool called the 4S Framework Studio (4SFS). 4S Framework is a set of open source frameworks used for model driven development. Studio is an IDE for that framework. The main brain behind the studio is Tamjeed Ahamed (twitter handle -> @mdtamjeed).

The session was held on 28th August. Both the Chairman, Mr. Raju Kanchibotla and Mr. Narasimha Rao were present and introduced us to the gathering.

First, I gave a corporate presentation of the company. Then I presented a few slides on the 4SFS. We showed the requirements for a small application - inventory movement register - and Tamjeed gave a demonstration building the application real time in front of the audience. If you are thinking what the big deal about it is, the functional JEE application is built and deployed without writing a single line of code.

The key takeaways for the members were:

  • As a programmer, write only business logic.

  • Think automation: If you are doing the same task a second time, write a program to do the task.

  • The best exercise is to write programs that write programs.

The session took more than two hours. All in all, we enjoyed presenting the studio and interacting with the audience. I wish CSI good success in their activities and am hopeful of more association with them in the future.

Back to my C++ Sudoku solver. Skiena's C program is built around the concept of backtracking, which he implemented in the reusable bactrack function. To take a small detour into backtracking, here's a brief explanation from Skiena's book.

"Backtracking is a systematic way to iterate through all the possible configurations of a search space. Those configurations may represent all possible arrangements of objects (permutations) or all possible ways of building a collection of them (subsets).

At each step in the backtracking algorithm, we try to extend a given partial solution a = (a1, a2, .... ak) by adding another element at the end. After extending it, we must test whether what we now have is a solution: if so, we should print it or count it. If not, we must check whether the partial solution is still potentially extendible to some complete solution."

My program got stuck in a few places. Remember, I was using C++ compiler on C code. Even after I could get the program to comple, it was not solving the Sudoku. After a few changes based on trial and error (i.e., using log messages and without stepping through debugger), I finally got it to work. The main change that did the trick was changing an if condition (see below).

The changes are:

  • backtrack parameter is boardtype* and not data. C++ compiler is strict on type checking.
  • Didn't use the typedef for bool. In Skiena's C program, bool is tyedef'ed as an int. I left it to whatever C++ defines bool as.
  • In read_board method, changed if (value != 0) to if ((value > 0) && (value <= 9))
  • Finally, instead of scanf and printf I have code to copy from the dialog and write to the dialog.

I have uploaded the whole Qt project to my mediafire page and it can be accessed here.


Log in

No account? Create an account