Posts

Efficient Programming?

Image
Hola! What is an efficient program? In a layman term - A program which does, what its "supposed to do", in a "fast" and "cheap" way... A program can be very fast... If we decrease the number of loops inside it By choosing the "right data-structure " which can be used to efficiently manipulate the data, the program uses etc... A program can be cheap... If it consumes less memory (RAM space while it runs) By using as less "Objects" as we can Or by again using right data-structure Ok... theory.. its always boring...  :-) Lets jump on to solving an interesting problem... Take up a role of   Server-side Developer of a reputed website company, where the first task given to you is to validate the user password! Here is the requirement - You should reject a password if it contains a "repetitive sequence". A password is said to contain "repetitive sequence" if it has same sequence repeated one after

GXT - ComoboBox with Multi select feature

Image
Hi There! :-) Its been a while since I am working on GWT(Google Web Toolkit) and its wrapper framework like ext-GWT (which is called as GXT) and have come across lots of new widgets and containers. One recent feature request, I had to work on recently, which caught my attention was Mutli-Select ComboBox. What does it mean ? Its a ComboBox (a widget which will allow user to edit - as well as select values from multiple options it provides) How its different from normal ComboBox? Multi-ComboBox allows you to select multiple values from options (unlike normal combo which allows to select only one value at a time) Now as I went on to analyse the implementation of this widget, I remembered a component from GXT called CheckBoxListView . Which is a list view comprising of CheckBox components. As I found this component perfect to select multiple values, I went on to integrate it with TriggerField . I thought of creating a Dialog widget which will act as ComboBox "option prov

Mutual Exclusion among 2 different classes

Hello There!, Recently I came across a very interesting problem, and the problem statement is as follows There are 2 classes called A and B, with the methods - methodA() and methodB(). The class definition vaguely looks like this. class A {   public methodA() {       statementA;   } } class B {     public methodB() {          statementB;    } } Now the 2 classes's methods contain a set of statements represented by statementA and statementB . Our goal here is to make these 2 statements in 2 different class, execute in a mutually exclusive manner. That means, when any thread executes statementA, none of the threads must be allowed to execute statementB. And when any thread executes statementB, none of the threads must be allowed to execcute statementA. Meanwhile, unlimited threads can simultaneously access statementA alone or statementB alone. methodA and methodB can be changed in any form (making them synchronized or whatever). But method signatures are not