Corruption…it stinks!

I happened to visit my area BBMP contact office today to submit papers to apply for khata. The revenue inspector there demanded a huge sum of money to process the application as though it was his birth right. I was so frustrated that I felt at some point like giving him one tight slap and hold his collar and tell him to do what the govt pays him for……what the heck….why does he need so much money to do his own bloody job! The entire system is so damn corrupted….it stinks! I wonder how this can be corrected. Now I didn’t pay him any money so I had to come back with my application…what next…hail RTI…most likely I will simply submit the application and then post a couple of RTI queries to move my file…might be a long drawn process but then I will have to face it…

People…you govt officials…politicians and all those out there who want to make that fast buck…remember one thing you only need enough money to lead a peaceful life. The more you run after it…the faster money will move ahead there will be no end to it. You swindle so much money…crores and crores but you can only spend whatever little you need. Rest can never be carried over. Be prudent…live and let live guys!!

Posted in Uncategorized | Leave a comment

Go veg…

Came across this nice article that gives you enough and more reasons to go veg….

http://findarticles.com/p/articles/mi_m0820/is_1999_April/ai_54232138/

Posted in Uncategorized | Leave a comment

It still sucks :(

yes… they heard me…you can now buy android apps from India…here is the updated list of countries from google

http://market.android.com/support/bin/answer.py?hl=en&answer=138294

But it still sucks coz I cant sell apps from India 😦

Posted in Android | Leave a comment

Android frustrations

Being an android developer in India its frustrating because google doesn’t let you sell apps from India. And there are host of all legal and tax issues for your friends in the us who try to sell on your behalf. There are sites which take care of all this and sell apps on your behalf but they take a large commission of an already low selling android market. But India being such a larger developer base, how can google not think of still enabling India in the list of countries to sell apps. It is really frustrating to say the least. The same apps iphone versions are so easy to sell…thumbs up apple and thumbs down google….

Posted in Android | 1 Comment

Working on your own…

I must say working on your own for yourself is probably very very tough. It is difficult to keep yourself motivated and focused. So many distractions and there is no one chasing you for work to be completed :-)….nywayz we are not too far from posting couple of apps on the android market soon…unfortunately google doesn’t support India as one of the merchant locations yet :-(…..so thanks my friends in the US for helping me sell these apps on the market. I’ll post the apk files on this blog in a while for people interested in checking out some of the apps…so keep visiting

Posted in Uncategorized | 4 Comments

Intents and Intent Filters

The android platform defines various “activities”. What are activities?? Loosely defined an activity is a piece of code that manages one user screen at a time. When you are writing a mobile application, you may have the need to write various activities. In order to enable communication between activities, we require what are called “intents”. In the beginning it took me sometime to absorb these concepts and hence I decided I write up a small note here so it might help others.

The activities are all event driven. For each event – called an “action” in android parlance, there could be an “event handler”. Now how do we define these? Here is where the android manifest file helps us. In the android manifest file, we define various activities. For each activity, we define a set of “intent-filters”. Think of the manifest file as a registry.When an app is launched, its registry is processed so android exactly knows how many activities are there and what kind of event can each activity process. Lets look at an example below,

<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
package=”com.sd.smartphone.app”
android:versionCode=”1″
android:versionName=”1.0″>
<application
android:icon=”@drawable/icon” android:label=”@string/app_name” android:debuggable=”true”>
<activity android:name=”.NotetakerActivity”
android:label=”@string/app_name”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
<!– Filter to register this activity to handle all editing of notes  –>
<intent-filter>
<action android:name=”android.intent.action.EDIT”/>
<category android:name=”android.intent.category.DEFAULT”/>
<data android:mimeType=”vnd.android.cursor.item/vnd.sd.notes”/>
</intent-filter>
</activity>
<!– Activity for displaying list of saved notes –>
<activity android:name=”.NotesList” android:label=”@string/pick_note”>
<!– Filter to register this activity to retrieve and display a list of notes –>
<intent-filter>
<action android:name=”android.intent.action.PICK”/>
<category android:name=”android.intent.category.DEFAULT” />
<data android:mimeType=”vnd.android.cursor.dir/vnd.sd.notes”/>
</intent-filter>
</activity>
<provider android:authorities=”com.sd.smartphone.app” android:name=”NotetakerContentProvider”></provider>
</application>
</manifest>

In the above manifest, there are 2 activities which have been defined. And each activity has a set of “intent-filters”. What happens is when a particular action for instance, android.intent.action.PICK happens within the application, android knows that there exists an activity called “NotesList” which can handle this particular action. Unless the programmer explicitly delegates this action to a different activity, android implcitly knows that NotesList activity can handle the PICK action. This is called “intent resolution”.

Posted in Android | Leave a comment

Aspect oriented programming

I asked this question to one of my developers one day….”what is your understanding of aspect oriented programming?” and this is what I got as a response…

Aspect oriented programming is the one wherein we define all classes in xml files and then allow them to be used between classes by injecting them….

wait a min…are we killing aspects or dependency injection or both. The answer pained me. These days its common to use frameworks like spring and hence concepts like AOP and DI. So I thought it will be worthwhile to give my version of what aspects are..

Aspects are cross-cutting functions that can be “applied” onto an existing piece of business logic code. As application developers the most concern that we have is ensuring that the logic of the application is perfect. As we do this, we are often required to do things like logging, auditing etc. These functions can be coded separately and then “advised” to pieces of code that require it without interspersing application code with all their code. Lets take it a little further…

Suppose for instance, I am interacting with a backend system to complete certain business operations. In my application, there could be multiple such systems which I will need to communicate to. There could be a scenario where one of these backend systems suddenly stops responding and my application would then throw a SystemUnavailableException…..I have a good reason to notify some of the important folks that a particular system is down so they take appropriate action. Would you like every developer of the application to take care of this? Perhaps not….So we develop the notification aspect. The notification aspect is then “configured”(refer to your specific framework’s documentation on how to configure) to run when SystemUnavailableException is thrown.

What we have done effectively is move out all the notification logic into an aspect that can be applied at will to any application code leaving the application business logic code blissfully unaware that certain smart things are happening in the background…

Is that a good enough explanation for an aspect? Leave a comment if so 🙂

Posted in Web technologies | 2 Comments

Leveraging ThreadLocal in a J2EE container for information propagation

This one is related to J2EE application development. Often application developers and a lot of architects are skeptical in working with threads in a managed environment. Loads and loads of java applications that run on high end app servers are getting written. And most of them have the application architected in several layers. I will present below an approach which would help propagate various information “clandestinely” within the application. This is not something new and many frameworks like hibernate (for session binding) use these approaches internally…so what is this all about??? Read further…

The J2EE application servers as well all know work with threads internally so when a given request is being processed, it is attached to its own thread of execution. Even if you are application concerns are well split into multiple layers, the same thread will go layer after layer and execute code. This is something that could be leveraged by applications smartly. Assume for instance I have a typical J2EE application that has a front end layer and a business logic/service layer. There could be backend interactions using implementations of the DAO pattern. It many applications, there could be app-wide information that is required to be used across many layers (example – user information). If there is some way to propagate this information to all layers without having to pass it to all methods, then it will make code that much cleaner and individual coders need not worry about many intricacies. This is where the current thread context comes in handy.

Here is the strategy -Get a handle to the currently executing thread and then set the value  in it(user information in our example).  You are done now – this information is available throughout the thread of execution…..lets look at sample code below,
public class ThreadContext {

private static ThreadLocal<ThreadContext> threadCtx = new InheritableThreadLocal<ThreadContext>();

/** Map of objects that can be added into the thread context **/
private final Map<String, Object> ctxMap = new HashMap<String, Object>();

/**
* <p>This method is to  set an object into the thread context</p>
* @param key
* @param value  void
*/
private void putObjInContext(String key,Object value) {
this.ctxMap.put(key, value);
}

/**
* <p>This method is to  get an object from the thread context</p>
* @param key
* @return  Object
*/
private Object getObjFromContext(String key) {
return this.ctxMap.get(key);
}

ThreadContext(){
//I have used a no argument constructor here. But if you want to default initialize
//anything you can use this place
}

public static ThreadContext getThreadContext(){
return threadCtx.get();
}

/**
* <p>Set the context back into the current thread</p>
*/
public static void setThreadContext(ThreadContext ctx){
threadCtx.set(ctx);
}
}

Here is the usage. Wherever the context is needed, this is what you should do..

ThreadContext.getContext().getObjFromContext(key);

Once the current request is processed, all the context related information is purged and the thread if returned to the pool. It is guaranteed that any information you put on the thread will remain synchronized so no one else other than the current user who is being served can access it. Secondly, once the execution is complete and before the thread if handed back into the pool all information is purged so data will not get shared.

Posted in Uncategorized | 1 Comment

My First Post…

Ok..here goes my first post on wordpress…:)…I tried so many different combinations to get a nice name for this blog but as usual most of the good ones are taken 🙂 . I never liked the second part of my name Babu. It makes my name sound odd is what I always think and always wished it was Bharadwaj instead….for some strange reason my parents gave me this name :). The only advantage with having a strange name is that online identities (such as this blog name) are easily available for you to take. That said, let me explain why I started this. Ideally I would like to have my own private space on the web to share many a thing I learn. But there is no time/patience to build one for myself from scratch so I am here.

What I will be doing here? – At this point I don’t know. But I am planning to put up posts on technology related findings and learning here so it might help that one random visitor with something that he might be looking for……so keep looking here for regular updates…

Posted in Uncategorized | Leave a comment