Sunday, 20 August 2017

Sunday, 1 February 2015

Fact about hashCode() in Java

Hash code method returns integer. If range of integer finishes then also two different object will have same hashCode. So it is not necessary that two different object will have same hashCode are equal.So, If the two objects have same name, then they would be equal, but still if their string field has different length, then their hashCodes will be different.
That is why, you should always use the same fields in equals and hashCode calculation.

Wednesday, 26 March 2014

Capability‬ Maturity Model (CMM)


####‪#‎Capability‬ Maturity Model (CMM)#####

--------------------------------------------------------------
The Capability Maturity Model (CMM) is a methodology used to develop and refine an organization's software development process. The model describes a five-level evolutionary path of increasingly organized and systematically more mature processes. CMM was developed and is promoted by the Software Engineering Institute (SEI), a research and development center sponsored by the U.S. Department of Defense (DoD). SEI was founded in 1984 to address software engineering issues and, in a broad sense, to advance software engineering methodologies. More specifically, SEI was established to optimize the process of developing, acquiring, and maintaining heavily software-reliant systems for the DoD. Because the processes involved are equally applicable to the software industry as a whole, SEI advocates industry-wide adoption of the CMM.

The CMM is similar to ISO 9001, one of the ISO 9000 series of standards specified by the International Organization for Standardization (ISO). The ISO 9000 standards specify an effective quality system for manufacturing and service industries; ISO 9001 deals specifically with software development and maintenance. The main difference between the two systems lies in their respective purposes: ISO 9001 specifies a minimal acceptable quality level for software processes, while the CMM establishes a framework for continuous process improvement and is more explicit than the ISO standard in defining the means to be employed to that end.

**CMM's Five Maturity Levels of Software Processes**
---------------------------------------------------------------

1. At the initial level, processes are disorganized, even chaotic. Success is likely to depend on individual efforts, and is not considered to be repeatable, because processes would not be sufficiently defined and documented to allow them to be replicated.



2. At the repeatable level, basic project management techniques are established, and successes could be repeated, because the requisite processes would have been made established, defined, and documented.


3. At the defined level, an organization has developed its own standard software process through greater attention to documentation, standardization, and integration.


4. At the managed level, an organization monitors and controls its own processes through data collection and analysis.


5. At the optimizing level, processes are constantly being improved through monitoring feedback from current processes and introducing innovative processes to better serve the organization's particular needs.

Tuesday, 25 March 2014

StringTokenizer in Java (Split the String in key value behavior)


StringTokenizer in Java (Split the String in key value behavior)

------------------------------------------------------------------------
StringTokenizer class provide the facility as similar String split() method,
but this class provided split the values on the base of Key value pair behavior.

import java.util.StringTokenizer;

public class TestStringTokenizer{
public static void main(String args[]) {
String checkSplit = "country=India," +
"state=Andra Pradesh," +
"city=Hyderabad";
StringTokenizer st = new StringTokenizer(checkSplit, "=,");
while(st.hasMoreTokens()) {
String keyCheckSplit = st.nextToken();
String valCheckSplit = st.nextToken();
System.out.println(keyCheckSplit + "->" + valCheckSplit);
}
}
}

o/p-

country->India
state->Andra Pradesh
city->Hyderabad

Open any file from java on any location of system


Open a file from Java 

-------------------------------------
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;

/**
* @author prabhat@ezeon
*/
public class OpenDesktopFile{
public static void main(String[] args) {
try {
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.open(new File("c:\\imp.docx"));
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
-------------------------------------------

Dockable Frame in Java Swing

Make a Dockable Frame in Java Swing.

---------------------------------------------------------------------------------------------

import com.vlsolutions.swing.docking.*;
import javax.swing.*;
import java.awt.*;
/*
 * @author Prabhat
 */
public class DockableFrame extends JFrame {
// our docking desktop
    DockingDesktop desk = new DockingDesktop();

    public DockableFrame() {
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        getContentPane().add(desk);
        setTitle("Chcek Dock Frame");
// first, create 4 dockable buttons (inner class below)
        DockableButton button1 = new DockableButton("Dockable 1");
        DockableButton button2 = new DockableButton("Dockable 2");
        DockableButton button3 = new DockableButton("Dockable 3");
        DockableButton button4 = new DockableButton("Dockable 4");
// first button at center
        desk.addDockable(button1);
// second and third button splitted vertically on the left of center
// first parameter is the "reference", second is the added dockable
        desk.split(button1, button2, DockingConstants.SPLIT_LEFT);
        desk.split(button2, button3, DockingConstants.SPLIT_BOTTOM);
// add the fourth button as a tab on the 3rd :
        desk.createTab(button3, button4, 1);
        SwingUtilities.invokeLater(
                new Runnable() {

                    public void run() {
                        setSize(800, 600);
                        validate();
                        setVisible(true); // realize on the event dispatch thread
                    }
                });
    }

    public static void main(String[] args) {
        new DockableFrame();
    }
// our basic dockable object
    class DockableButton extends JButton implements Dockable {

        DockKey key;

        public DockableButton(String label) {
            super(label);
            this.key = new DockKey(label); // most simple dockkey constructor
            setPreferredSize(new Dimension(200, 200));
        }

        public DockKey getDockKey() {
            return key;
        }

        public Component getComponent() {
            return this;
        }
    }
}
------------------------------------------------------------------------------------------

Note : You need vldocking.jar file to execute this program.