Friday, January 23, 2015

Solaris Command to Show Long argument list of a Running Process

One of the problem with ps command, which is a popular tool to find any processes along with grep command in Solaris operating system is that it doesn't show full command line argument of process. This means if you are doing grep on any text which appear at tail end of long command line, you will likely not able to capture that process by using ps and grep. This is dangerous because it may lead you to assume that certain process is not running and you may restart it again, despite its being running and only because you didn't find the process. This is quite common while running Java process in any UNIX operating system e.g. Solaris, Linux, IBM AIX etc because Java process usually has long list of arguments e.g. system properties, JVM options,  and name of main class. I have faced this problem quite few time even after using ps -ef  option. Until now I have not found any compelling solution for this problem which will work on all UNIX systems, except for Solaris, which  I am going to share with you guys. So, my only advice is to put the keyword in head of long command line argument and try to keep Java command line as small as possible. Also prefer using ps -auxww over ps -ef,  former better display long command line than later and you have higher chance of capturing the process by using grep with tail keywords.

Wednesday, January 21, 2015

Difference between Functional and Non-Functional Requirements in Software development

Gathering the correct and complete requirement is one of the most important thing in software development. Incorrect and incomplete requirement are main reason of why project fails. If you are in software development, you may have come across terms like functional and non-functional requirement. If you are wondering why a prototype take a 2 weeks but actual application development requires around 3 to 4 months of development; think of non-functional requirement. When someone told you to build a software, what they tell you is what that software should do e.g. allow you to trade on certain market, but they don't tell you about security, performance, load and other stuff, this is what I called non functional requirement. Obvious difference between functional and non-functional requirement is, former is specified by its users, business analyst and its part of software's feature list, for example functional requirement of a trading application is to receive order, enrich, transform and send it to Stock Exchange, but non-functional requirement is not specified by user, its rather thought by Software architect, Subject Matter Experts, Technical lead and Support peoples. For example, for this same trading application non-functional requirement could be Failover and Recovery, logging, auditing, latency and other performance characteristic that, application should be able to run continuous, can process 5K orders per second etc. Support people can also ask functionality require to add user, give access, revoke access, monitoring etc. Every application in software development has one or other kind of non-functional requirements. In this article, we will learn more about difference between functional and non-functional requirements in software and product development.

Tuesday, January 20, 2015

Java Clone Tutorial Part 2 - Example to Override with Mutable field

This is the second part of Java tutorial on Cloning, In first part we have seen how clone method works in Java with a simple example of cloning object, with primitives and Immutable. In this tutorial, we will take one step further and override clone method for creating clone of object with mutable field. In our case mutable field is a Collection here, to be precise a List. Since default implementation of clone() method only does shallow copy of objects, it can create issue, if original object contains mutable object or Collection classes. In our example, we have a class called Programmer, with String name, int age and List of Certifications. When we override clone() method inside Programmer class, we need to explicitly take care of this List, otherwise, both original and cloned object will point to same Collection in Java heap, which means, any change e.g. adding a new Certification in original object will also reflect in cloned object or vice-versa. Since an object should be independent of it's clone, we need to fix this issue by applying deep cloning techniques. Along with this example of overriding clone in Java, In this Java clone tutorial part 2, we will also take a look at some Java best practices for implementing correct clone method, disadvantages and shortcomings of cloning in Java and in particular clone method and finally, when to use clone in Java.