Sunday, January 31, 2010

10 Commandments for Java Developers

1. Add comments to your code
2. Do not complicate things - Means don’t come up with complicated solution for simplest problems
3. Keep in Mind "Less is more" is not always better - Means when necessary write all required code
4. No hard coding please.
5. Do not invent your own frameworks. - use available superb frameworks like Struts,JSF or Spring
6. Say no to Print lines and String Concatenations
7. Pay attention to the GUI - Look and Feel always matters
8. Always Prepare Document Requirements
9. Unit-test. Unit-test. Unit-test - Always do unit test
10. Remember quality, not quantity.

Tuesday, January 26, 2010

Framework for cloud computing using java

Hi,

Recently, i was searching for java based framework suitable for cloud computing and i suddenly came across grid gain.

GridGain is an ideal platform for Native Cloud Applications. GridGain provides developers with powerful and elegant technology to develop and run applications on private or public clouds.

GridGain is developed in Java and for Java developers and it is a natural extension of the latest Java development methodologies including annotations, integration of Spring and AOP-based grid-enabling.

For more details http://www.gridgain.com/

Friday, January 22, 2010

Getting square block characters when carriage return used in MS Excel 2003

Hi,

Recently i was facing a strange issue with JXL API for excel sheet generation using JAVA, the data entry screen was fine but when i was generating reports, i got some strange characters at each carriage return. This issue only happened in MS Excel 2003, this worked fine in other office versions.

Actually this issue only appeared in some European countries, worked fine in Asia.

So, i tried replaceAll method to replace this character with blank spaces like this ::

reportValue.replaceAll("[\\r\\n]", "");

This worked fine but it removed all my carriage returns too..

So, i tried below code which removed that square block character and restored my keystrokes.

reportValue..replace('\r',' ').replace('\'',' ');

This worked absolutely fine in All office versions and all countries for both europe and asia.

Cheers,

Ujjwal Soni

Thursday, January 14, 2010

what is 'is a' and 'has a' relationship:

The is a relationship is expressed with inheritance and has a relationship is expressed with composition.


Both inheritance and composition allow you to place sub-objects inside your new class. Two of the main techniques for code reuse are class inheritance and object composition.
e.g.,
is a --- House is a Building
class Building {
.......
}


class House extends Building {
......... 
}

has a -- House has a bathroom
class House
{
  Bathroom room = new Bathroom() ;
  ....
  public void getTotMirrors()
  {
    room.getNoMirrors();
    ....
   }
 }
Inheritance Vs Composition
Inheritance is uni-directional. For example House is a Building. But Building is not a House. Inheritance uses
extends key word. Composition: is used when House has a Bathroom. It is incorrect to say House is a Bathroom.
Composition simply means using instance variables that refer to other objects. The class House will have an instance variable, 
which refers to a Bathroom object.

Article taken from Oracle Magazine march 2008 issue