Wednesday, January 9, 2008

Sharing Session Data Across Different Webapps

I recently had an interesting task where a chunk of data had to be shared across different webapps in order for the application to do its job appropriately. The first thing that came to my mind was to implement caching and use that as the in-memory storage for storing frequently used data. By doing this we can store all the shared data and fetch it from the cache. However I was not very sure and this prompted me to have a discussion as well with couple of my friends and they felt that caching was a good idea too. They also suggested that i could also merge the other webapps into one single webapp. This was not an option as the other webapps were third party tools and the requirement was to only work on a very small portion of the third party tools.

If you guys have done it differently or have a better idea do let me know!! Another way of sharing session data is to add crossContext="true" to the context.xml in Tomcat which would allow you to access another context from a given context. The ServletContext would then be used as the in-memory storage for frequently used data. However if this approach is taken one would need to implement thread safety properly. Also according to the Servlet Specification Session is scoped to a ServletContext and ServletContext is per webapp and it is an in-memory or an object container if you like for the owning webapp. Hence this is a bad practice and probably not the best approach.

Swift Domain Name Search

Here is a link http://www.swiftdomainsearch.com I found on the web to quickly find out what domain names are available. It does a pretty neat job if it as well. Try it out in your spare time and let me know what you guys think of it as well.

Tuesday, January 8, 2008

Thoughtworks Geek Night Gaming Event

Thoughtworks has organized a gaming event for all you gamers out there. If you guys are interested in playing some really cool games then go ahead and register yourselves for this event. This event is being held in the pune office. For those of you who have not heard about Thoughtworks before here is the url to the company website. http://www.thoughtworks.com/




For more info click on the link below :-

http://groups.google.com/group/ThoughtWorks-Bangalore-Geek-Nights/browse_thread/thread/47c6d6db93c39cd4?hl=en

Thursday, January 3, 2008

Defining Interfaces Java

Below are the two variants of defining and declaring an identical interface. The interface is essentially the same but only differs in the way it is coded.

Snippet-1
------------

public interface UserManager {

public abstract void addUser(User user);

public abstract void removeUser(User user);

//blah blah

}

Snippet-2
------------

public interface UserManager {

void addUser(User user);

void removeUser(User user);

//blah blah

}

Snippet-1 is more detailed or explicit in terms of access specifiers whereas Snippet -2 is implicit in terms of access specifiers. Now the question to be asked here is how should we define interfaces in our code. I did look at the Java Coding standards and there was nothing much I could find over there.

Essentially even though they differ in the way it is coded the access specifiers are public and abstract implicitly even if you dont specify them explicitly according to the Java Language Specification. In my opinion I think its good practice and more clear if you define interfaces and its methods explicity the way its done in Snippet-1 as opposed to Snippet-2. What does the readers of my blog have to say about this? Please share your opinions about the same!!

Friday, October 26, 2007

Five mistakes that will ensure project failure

The following is a very interesting article by Joel Spolsky who talks about the five-step guide to ensure project failure.

Five-easy-ways-to-fail

Tuesday, October 23, 2007

Proper use of Generics

Yesterday I was asked to review code written by an ex- colleague of mine for a particular module. As I was reviewing I came across these lines of code

Snippet of the code:-
--------------------------
Node node = // does something to the get the node;
List < object > nodes = new ArrayList < object >();
nodes.add(node);

As soon as I saw this I educated him on the proper use of generics. It should have been written this way

Proper snippet of the code:-
-----------------------------------
Node node = // does something to get the node
List < node > nodes = new ArrayList < node > ();
nodes.add(node);

This brings in type safety and the compiler ensures that you only add objects of type node into this list. As we all know that Java is a strongly typed language and the addition of generics to the Java API has only increased the type safety.

Thursday, October 18, 2007

An Excellent Article on Clean Code

I happened to come across this wonderful article about writing clean code and I thoroughly enjoyed reading it.

So here you go readers have a look at the article I am talking about
http://www.objectmentor.com/resources/articles/Clean_Code_Args.pdf

Let me know what you guys think? I definitely give this article a thumbs up!!!!!