How to setup local cvs environment in ubuntu

For development, repository is very important. In this respect CVS has been playing a very good roles over development arena.

The Concurrent Versions System (CVS), also known as the Concurrent Versioning System, is a client-server free software revision control system in the field of software development. Version control system software keeps track of all work and all changes in a set of files, and allows several developers (potentially widely separated in space and/or time) to collaborate. Dick Grune developed CVS as a series of shell scripts in July 1986. There was a similar system available earlier in the mid-70’s developed by John Humbert.

Now, I will discuss how to setup cvs environment in ubuntu
At, First you have to open system->Administration->Synaptic Package Manager. Search “CVS” and mark it for install. Complete the installation process by click apply button.

Now you can follow this:

command for local cvs environment

Now, you can access local cvs using netbeans or other IDE. In netbeans, cvs root like following


Example of factory pattern in java

1. Introduction
2. Example in java

The factory pattern is the most common pattern in object oriented programs. A Factory pattern is one that returns an instance of one of several possible classes depending on the data provided to it. Usually all of the classes it returns have a common parent class and common methods, but each of them performs a task differently and is optimized for different kinds of data.

Example in java
Here, A program for detecting first and last name according with given full name. First and last name should be separated with “,”[comma] in given full name.

Class for storing first and last name

class Namer {

    protected String last;
    protected String first;

    public String getFirst() {
        return first;

    public String getLast() {
        return last;

Class for detecting first name if given name contains only first name

class FirstFirst extends Namer {

    public FirstFirst(String s) {
        int i = s.lastIndexOf(" ");
        if (i > 0) {
            first = s.substring(0, i).trim();
            last = s.substring(i + 1).trim();
        } else {
            first = "";
            last = s;


Class for detecting last and first name

class LastFirst extends Namer {

    public LastFirst(String s) {
        int i = s.indexOf(",");
        if (i > 0) {
            last = s.substring(0, i).trim();
            first = s.substring(i + 1).trim();
        } else {
            last = s;
            first = "";


Building the factory
Now our factory class is extremely simple. We just test for the existence of a comma and then return an instance of one class or the other:

class NameFactory {

    public Namer getNamer(String entry) {
        int i = entry.indexOf(",");

        if (i > 0) {
            return new  LastFirst(entry);
        } else {
            return new FirstFirst(entry);


Now using factory class

public class Main {
    private static Namer namer;

     * @param args the command line arguments
    private static NameFactory nfactory = new NameFactory();
    public static void main(String[] args) {
        String text="islam, shaiful";
        namer = nfactory.getNamer(text);