Sunday, June 20, 2010

Guava or Google Collection library

Guava or Google Collection library - just started to play with it. One thing attracted me the most is MapMarker which resembles the behavior of ConcurrentMap with eviction timeouts and choice of soft, weak references. Objective of the project says "Productivity aids to Java Programmers", Still exploring to see how it's useful in real context...



Loads of Material In reference to Guava,
http://jnb.ociweb.com/jnb/jnbApr2010.html
http://scaramoche.blogspot.com/2010/05/googles-guava-library-tutorial-part-1.html
http://code.google.com/p/guava-libraries/

Saturday, June 19, 2010

Unit Tests - "Written Once and Forgotten Forever"

I have come across many unit test cases that are written once and forgotten for ever, with all the dataset/environmental dependencies in it. What is the importance of dataset/environment? Let's take an example, observe the test case below.

public void testEmpFinder () {
//Weird Test case for Fun!!!
String result = "JOHN";

//Passing employee id returns employee object.

//verify the name matches.

Employee emp = EmpFinder.find(1);


assertEquals(emp.getName,result);


}


What's wrong? The developer had made an assumption, that on querying with employeeid='1' will return employee with the name "JOHN". The data could be coming from a database table "EMPLOYEE". But It’s very evident this test case would fail if run on an environment where the employeeid='1' data doesn't exists. This makes the test cases obsolete the moment they are written.

Approach

1. Save Insert/Delete datascript, that could be run on test setup () and delete test data on completion of test.

2. You could use something like DBUnit (http://www.dbunit.org/) which exports and imports the database data into an XML dataset. - Not sure of DBUnit support for modern day ORM's (Hibernate).

Conclusion:

Unit tests should match & sustain life time of source, after all its a guarantee card to your source code. We just looked at database dependency for example, how about dependencies such as JMS, Content Repository, LDAP etc. Writing a test case with all its data & environmental dependencies Mocked & externalized is an Art.

Chekout In Dzone

Wednesday, June 16, 2010

VisualVM - Simple Profiler

VisualVM is a handy tool just like the JConsole, with additional features of a commercial profilers. You could profile your application by CPU & Heap utilization (by class/method). You can even profile a server remotely, check out for documentation.




It's a must to have tool for java developers...

Reference:
https://visualvm.dev.java.net/features.html
http://blip.tv/file/1582849

Tuesday, June 15, 2010

Is flexibility enemy of standardization ?

I was thinking about evolution of java & open source world. What comes to my mind is the flexibility it offers to build your own stack of tools & technology when you start a project, cool!!! isn't it. You could explore, develop, cutting edge, unknown, unnamed open source project in your project....

But software is not about using cool technology all the time, isn't it ?
  1. What about skill set to manage and maintain it ?
  2. What about support for the technology and open source used ?
  3. What about wear and tear of changes happens over the life cycle ?
I tend to feel too much of flexibility leads to problems, which are unnoticed during the architecture and development of the project and get's uncovered during maintenance phase. Same application developed in .net takes lesser effort than java, what do you think is the reason ? Why every java projects are different by technology rather than business ? Is this the price to pay, to use an open platform independent languages & specifications ?

Architects come up with cool stuff, believe me it's the least used feature in the actual project. To sum it up, flexibility to choose the specification, implementation, technology, open source, commercial blah blah!!! leads to problems in later stages of the project, which very few people have stayed long enough to see them.
It's also important to consider other aspects like skill set, proven architecture, standardization, support and etc in a software architecture than just being cool......

After all this is my blog, and i am bored of being cool :) ...

Friday, June 11, 2010

How to post XML code on Blogger

Paste your XML content here and click on encode. Copy the encoded content and paste in your blog. It safes lot of your time encoding it yourself....

This method is not applicable inside the application server. See the J2EE spec, e.g. J2EE1.4 Section 6.6

javax.jms.IllegalStateException: This method is not applicable inside the application server. See the J2EE spec, e.g. J2EE1.4 Section 6.6
2010-06-10 16:18:51,656 503469 ERROR [STDERR] @main at org.jboss.resource.adapter.jms.JmsSession.checkStrict
(JmsSession.java:754)

2010-06-10 16:18:51,656 503469 ERROR [STDERR] @main at org.jboss.resource.adapter.jms.JmsMessageConsumer
.setMessageListener(JmsMessageConsumer.java:174)


Fix:
Adding the following in the file, default/deploy/jms-ds.xml (or) production/deploy/hajndi-jms-ds.xml based on the profile used, fixed it.

<config-property name="Strict" type="java.lang.Boolean">false</config-property> under "<tx-connection-factory><jndi-name>JmsXA</jndi-name>"

Thursday, June 10, 2010

Opensource entry into Cloud space :)

Read this article at Dzone yesterday, sounded very interesting. As a matter of fact, it's an opensource project that could give you all that GAE or EC2 can provide with all opensource stack.

The beauty is, you can have your own cloud built with in your firewall and have your apps follow GAE API to be portable, how cool it is :) checkout - Typhoonae

Wednesday, June 02, 2010

MongoDB

MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide rich queries and deep functionality).

I strongly feel the cloud players should adopt this approach, since so much of knowledge, best practices and standardization has gone into the design of traditional RDBMS Systems. I strongly feel ditching them is not the best way to go....

I haven't tried Mongo myself yet, would do soon....


Reference:
http://www.mongodb.org/