Java Project Maintenance – 5 Tips

No doubt that, Java is the leading enterprise software development language in current context and it comprises with vast technology stack to support many (good to say all) sectors which are deal by enterprise systems. It is rich with thousands of APIs and millions of developer community who willing to help and share the experience.


Scope wise or functionality wise, an Enterprise Java Project is usually inherits the complexity. This complexity causes for headache in all of the software development life cycle phases and especially in maintaining phase of the system. Maintenance involved bug fixing, adding new functionalities, trace back historic records and give reasons for the system behaviors, migrations, back up, etc… In this article I try to point it out 5 tips that we need to consider to do a good job in system maintaining.

1. Documentation

Larger systems are very difficult to understand by going through the code line by line. Having with component designing documents, API designing documents it is very easy to narrow down the component or sub component that we need to see if it needs to fix or add new functionality. Even we can get to know the use case also, if we have the Requirement Spec. Each of new CR should properly versioned and documented and it will help to get deep understanding on current system. For a new comer also it is a great help that if he can refer a good documentation of the system. In maintenance perspective system documentation is the most crucial factor that will affect to do better system maintenance.

2. Logging

Logging is a basic discipline that we follow when we are developing the system. Programmers use many logging tools in application level or beyond the application level. Logging involved load balancer logs, server logs and back end db level logs (Oracle PL/SQL programs logs). It is very important to convince, that programmers what it needs to log, at which place and in which log level going to use. If not once the system has deployed it is difficult to trace back the issues. Another important aspect is how to use files for the logging, especially is it going to use different logs for each of the component or going to use central log for every component. System maintainer considers the convenience of the log tracing and System user considers the performance of the system.

3. Employees

This aspect is not a technical thing but relate with the people management. Any given time an employee can jump to a new company and there for it needs to have a backup resource if that person is critical to the system. It should have a proper knowledge transferring mechanism, so the backup person can take over the system if it needs. This aspect help for a better system maintenance and both company and customer will proceed with a good customer relationship.

4. Issue Tracking 

It is very important to track the issues when a system is in maintenance phase because company needs to identify what are the places it needs to have further expansions and bug fixes. There are many tools in the market for this purpose and some of them are free to use. Some companies use issue tracking systems as a knowledge base and whenever a similar issue is arising they will refer the earlier case to resolve it. Some of the SLA oriented companies use these systems for their billing proofs too.

5. Code Base Management

Unprofessional code base management leads system’s code base mess. This is very important discipline because large systems keep on adding new things and changing the existing code base. So it increases the complexity day by day in code base aspect. For this process also there are many tools are available in the industry and some of the famous tools are Subversion and GIT. When the code base becomes larger it needs to clean up repeating code segments and organize code base in more logical manner. Some people bit reluctant to change the code base because they consider the effects of it for the existing production functionalities, but after couple of months or even couple of weeks it will mess the code base and make code base more complicate. Code review also needs to execute in periodical manner by the senior developers to point out juniors programming wrong disciplines. Apart from that this process will help to save the code base consistency. .

I like to see these 5 tips will help you to overlook when it designs the system and itself at the maintenance phase.


Arrys.sort and Collections.sort

Arrays class and Collections are classes which used to sort arrays or lists contain the objects. Main difference of both two is Arrays.sort for sorting only arrays and Collectins.sort for sorting lists.

Arrays.sort method

Based on array type there are many sort method implementations exist in Arrays class. Note that each of these methods needs an array as an argument. If we are going to sort our owned type then we need to implement Comparable or Comparator interfaces that we have discussed above the post. In that case we can use

static void sort(Object[] a) for natural ordering or

static <T> void sort(T[] a, Comparator<? super T> c) for Comparator based sorting.

Since sort method is static we can use these methods without instantiating the Arrays class.

import java.util.Arrays;

public class ArraysSortTest {

public static void main(String args[]) throws Exception {

int array[] = { 2, 5, -2, 6, -3, 8, 0, -7, -9, 4 };


for (int i = 0; i < array.length; i++) {

if (i == 0)



System.out.print(“,” + array[i]);




Collections.sort method

As I described before, this method only accepting list based data structures. Similar to Arrays.sort there are many list based overloaded methods for sort. For the types that we have created we can use following favor of sort methods.

static <T extends Comparable<? super T>> void sort(List<T> list)

Sorts the specified list into ascending order, according to the natural ordering of its elements.

static<T> void sort(List<T> list, Comparator<? super T> c)

Sorts the specified list according to the order induced by the specified comparator.

I have copied method description from the java doc directly is quit explainery to understand.

import java.util.ArrayList;

import java.util.Collections;

import java.util.List;

public class CollectionsSortTest {

public static void main(String[] args) {

List<Integer> list = new ArrayList<Integer>();








for (Integer integer : list) {





Java Object Sorting

Object sorting is not a small topic and even I can not explain it completely in a small blog post, I tried to summarize important areas that a normal java programmer needs to know in day to day programming. Java programmers can use this post to refresh the knowledge about the java object sorting and for a new comer also can use this to understand how Java favors of object sorting.


Comparable and Comparator

Whole Java sorting mechanism is based on one of the above sorting interface. The practical usage is depends on the system architectural design and both interfaces are equally rich in object sorting. Some designers do not like to implement interfaces in domain objects. They like to see them in pure attributes with corresponding setters and getters. They came to that decision because in that case they can use Comparator interface to sort the objects with having more control on sorting attributes. But still designer may like to put sorting logic inside the domain class because he is sure based on which attributes this object could sort.

Comparable example:

public class Vehicle implements Comparable { 

      private int vehicleId;     


           public int compareTo(Object arg0) {

             Vehicle vehicle = (Vehicle) arg0;

                     return (this.getVehicleId() < vehicle.getVehicleId()) ? -1: (this.getVehicleId()> vehicle.getVehicleId()) ? 1:0 ;


       public int getVehicleId() {

            return vehicleId;


       public void setVehicleId(int vehicleId) {

            this.vehicleId = vehicleId;



When we are implementing Comparable interface we have to implement the compareTo method and it takes comparing object as an argument.

Comparator example:

import java.util.Comparator;

public class VehicleIdBasedComparator implements Comparator <Vehicle>{


     public int compare(Vehicle vehicle1, Vehicle vehicle2) {

         return (vehicle1.getVehicleId() < vehicle2.getVehicleId()) ?-1:

(vehicle1.getVehicleId() > vehicle2.getVehicleId()) ? 1:0 ;



Here it implemented Comparator interface and corresponding campare method. It takes comparing two objects as arguments. Note here we can come up with many comparator classes with deferent compare method implementation. It means we can change the logic inside the compare method and we can compare objects based on deferent attributes in Vehicle class.

In practical usage we can used both implementations to sort objects. I will discuss the practical usage of above implementations in next sections of the post.  Following table describes important things that you need to know about Comparable and Comparator interfaces.

Topic Comparable Comparator
Package java.lang.Comparable java.util.Comparator
Method int compareTo(Object o1) int compare(Object o1,Object o2)
Implementation Considerations Sorting logic must be in same class whose objects are being sorted. Hence this is called natural ordering of objects Sorting logic is in separate class. Hence we can write different sorting based on different attributes of objects to be sorted.E.g. Sorting using id,name etc.
Sorting method This method compares this object with o1 object and returns a integer.Its value has following meaning
1. positive – this object is greater than o1
2. zero – this object equals to o1
3. negative – this object is less than o1
This method compares o1 and o2 objects. and returns a integer.Its value has following meaning.
1. positive – o1 is greater than o2
2. zero – o1 equals to o2
3. negative – o1 is less than o1

Why it is such important to use View Objects

Current enterprise application development domain, MVC  based development  is a common thumb of rule. Last couple of days I designed a Java Spring MVC based application for my client. I thought to write a blog post on View Object’s importance in application design domain and hope others will harvest design knowledge from it.

View Objects are the objects we use to represent data on web pages. In MVC based development’s view object plays it role between the controller and the view layer. When we need to show information on a web page or when we need to take user input from a front end, view objects come and rescue us. Most of the Java frameworks like Spring, Structs, JSF support for view object binding between the view layer and the controller layer and usually named as backing bean binding.  Its important to know difference between domain and view objects different. Domain objects represent actual domain specific artifacts and view object only for user interaction. Some developers are directly using domain objects as views and that will lead to a complex and unmaintainable application design.

Think a scenario a GET request coming from a browser for a resource. That request ask for a shoe shop. So user needs to see current exist shoe brands. In this case we can use view object to set our exist brand names to it and  front end technology can show them to the user.

public class ShoeShopView {

private List<String> availableBrandList;

public List<String> getAvailableBrandList() {

// get data from a service and return a String List



So we can use view objects to push data to the front end and show them to the user. When data come from the user’s end we can use view objects to pass data to the server. As an example we may need only user’s identification number and application internally access a service and retrieves related information for that number. So in this scenario we do not need information which we can retrieve from the internal service. We can clearly identify that this view object does not need to represent a User domain object because it only deals with the user’s inputs.

In case of a complex front end application needs to use reusable front end components with the help of  Tiles sort of technology. View objects come to handy in this kind of scenario and we can design the system with component based jsp pages with view objects. View objects help to design much decouple jsps with help of it. Lets take we may need to show a form to a user and which needs to take decoupling objects data. In this case we can create partial forms and concat them according to the generating form.

Install OpenOffice 3.2 in Fedora 12

Default Fedora installation comes with AbiWord installation and it helps greatly to our day to day word processing works. Only word processing is not enough todays context and we mostly need to create presentations, drawings and do some basic maths calculations. For our world Sun gives OpenOffice as a complete office package as Microsoft does.  In this blog I talk about the openoffice 3.2 installation in fedora 12.

step 01:

OpenOffice used sun JRE as execution platform. So first it needs to install JRE in you’r machine. You can download new JRE from sun site  and install it (

Note : Adition to JRE installation it may need to install sun SDK if you plane to do some programe stuff  with JAVA SE. If you plane to install SDK then it install both development environment and also JRE. For that follow below steps.

Download SDK rpm package (Currently version is jdk-6u20-linux-i586-rpm.bin) and follow steps to correct installation.

Step 02:

After installation JRE then you can download OpenOffice package from OpenOffice download site ( Please note that to choose correct OS and 32/64 bit version.

Step 03:

Then go to package download directory and extract the package.

  1. tar xvzf OOo_3.0.0_LinuxIntel_install_xxxxxx.tar.gz
    This will create a source directory with the installation. The directory will have a rather long name but be prefixed by “OOO3…”.
  2. su to root, if necessary, and navigate to installation directory, the OOO3… source directory.
    Since the default packaging of for Linux is RPM, you will likely need to be root to run the rpm command.
  3. cd into the RPMS subdirectory of the source directory.
    You should see a lot of rpms here and one sub-directory called “desktop-integration”.
  4. Install this new version by typing rpm -Uvih *rpm.
    By default, this will install OpenOffice in your /opt directory.
  5. Finally, cd to desktop-integration. Depending on your package manager/system, install the appropriate desktop interface. For Fedora it needs to choose red-hat based openoffice.org3.2-redhat-menus-3.2-9472.noarch.rpm. So issue rpm -Uvih openoffice.org3.2-redhat-menus-3.2-9472.noarch.rpm command.

Step 04:

Still things may be not working. It may be rise “/opt/openoffice.org3/program/soffice.bin: error while loading shared libraries: cannot enable executable stack as shared object requires: Permission denied” issue. You need to execstack some libraries.

(execstack is a program which sets, clears, or queries executable stack flag of ELF binaries and shared libraries – man pages)

execstack -c /opt/
execstack -c /opt/
execstack -c /opt/

Now you can enjoy OpenOffice facilities in you’r favorite Fedora distribution.

Installing mysql gem in Fedora12

When I try to install mysql gem in fedora 12 new distribution I had to faced some issues. So I think the way I figured out may help to others also to get rid this issue. First I mention what I have earlier installed in my machine.

  • ruby(1.8.6)
  • rubygems (1.3.5)
  • rails (2.3.5)
  • Mysql Server version: 5.1.41 Source distribution and client

So what I need was to configure mysql which can be used in my rails projects. To do that follow the below steps as those are listed.

  • log as root and install ruby-devel and mysql-devel. These liabraries provide lot of neccery configuration instructions needs to mysql gem.
# yum install -y ruby-devel 
# yum install -y mysql-devel

  • Then fire normal gem installing command as

# gem install -y mysql -p http://proxy_address:port — –with-mysql-config=/usr/bin/mysql_config

If u are not work under proxy you can eliminate “-p http://proxy_address:port&#8221; part.

I think this will help you for your developings.

Each firefox user with owned user profile

Most of the web users love to use Firefox because it is the greatest browser still present in the world. You may have faced same experience as I, which is same pc same user accont used by many users. We are going to experience clouding world and we are not depend on the Machine os. Recently Google also announced they are going to make chrome os as a web os. Though there are lot of Web Operating Systems we are not familiar with them as we do with firefox. Of course firefox is not a web os but it seems like one of that. Amazon cloud supports only on Firefox. There are lot of add-ons which make Firefox as webtop.


So I think its better if Firefox works as a normal webos. Then anyone who work on same user account in the same machine will not be a issue when dealing with the web. Firefox will handle all the user based settings. Users only have to log to the user account of the Firefox and customized profile will be prompt to the user by Firefox.