Basic Paradigms

What is POM.xml
A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects. Examples for this is the build directory, which is target. Super POM is Mavens default POM. All POMs extend the Super POM unless explicitly set

Maven works in two modes in Command Prompt –
Interactive Mode – Takes command one after another
Batch Mode – takes all command at once

Archetype – Archetype is the one which defines the type of project and project structure. i.e. mvn archetype generate
ArtifactID – Specifies the name of the project.
GroupID – Group Id is one by which similar products or components are tied together under one groupId
i.e.

org.springframework
org.apache
org.commons

If you don’t specify the package name during creation it will take the groupId as package name for classes.

Types of Repo
Remote Repo is of Two type – Internal and External

  1. Central Repo-is mavens own repo accessed over mvn.com
  2. External Repo– are those whose JARs are provided by organizations like IBM for DB2. Those JARs are initially not available in Central Repo.Paid drivers are not available in Central repo rather available in organizations repo
  3. Internal Repo-Internal repos are the one provided by working organization.The main goal of such repos are to provide stable JARs and avoiding downloads of unstable jar directly from Central or external repos and to avoid network traffic

Apart from the above we have one more repo called local repo.
Local Repo – Local repo is the one which we have in the development system under .m2 folder. Local repos would be holding old JARs even when you run clean command which does nothing more than cleaning .class files. Inorder to get rid of old JARs we need to purge

purge local repo

Other Notable Points

  1. Maven is intelligent when you run install it would instatiate before phases(validate,compile and test).When one java file is changed in the list of 100 only 1 file would be compiled rather than 100 files
  2. mvn install – will deploy the JAR fils in the local repo(local .m2 folder) where as mvn deploy(disabled by default) – will deploy the JAR in the remote repo(Internal Repo)
  3. mvn compile – will compile only the java files in the source folder not the java classes in the Test Folder
  4. The Scope of the dependency JARs would be PROVIDED incase you are planning to deploy your code in environment which has someother higher version of JAR than dev environment.The default scope is compile.Though scope is compile the JARS would be available till target container.
  5. If the Team has completed coding for release then the JAR files would be named as RELEASE (or) FINAL.If the Project is still under development than the JAR would be named as SNAPSHOTThis is to make other development team to understand that there would be still code changes accompanied with JAR.
  6. .m2 folder should not be created manually.When you create your first project(maven project) .M2 folder would be created on its own.

An artifact in maven is a resource generated by a maven project. Each maven project can have exactly one artifact like a jar, war, ear, etc.Each maven project has a unique identifier consiting of [groupId, artifactId, version]. When a maven project requires resources of another project a dependency is configured in it’s pom.xml using the above-mentioned identifier. Maven then automatically resolves the dependencies when a build is triggered. The artifacts of the required projects are then loaded either from the local repository, which is a simple directory in your user’s home, or from other (remote) repositories specified in you pom.xml.

Now the once mvn install is done the same snapshots are available in repository location as below

Two Dimensional Arrays (Array of Arrays)

 //Seating Arrangement for 20 Seats
 int arrSeating[][] = new int[4][5];

 //No of Items Produced in Hr By Days in Month
 int arrProdHrByDaysInMonth[][] = new int[30][24];

Two Dimensional Arrays(Array of Arrays of Arrays)

 //No of Items Produced in Hr By Days in Month by Month
 int arrProdHrByDaysInMonth[][][] = new int[12][30][24];

Jagged Arrays
array of arrays such that member arrays can be of different sizes

Looping through ArrayList

         	//Iterate over Collection
		for (Iterator iterator = arrNames.iterator(); iterator.hasNext();) {
			String object = (String) iterator.next();
			System.out.println(object);
		}			
		
		//Iterate over array or Collection
		for (String string : arrNames) {
			System.out.println(string);
		}		
		
		//Iterate over array 
		for (int i = 0; i < arrNames.size(); i++) {
			System.out.println(arrNames.get(i));
		}
		
		//Iterate over array using Temporary Variable
		for (int i = 0; i < arrNames.size(); i++) {
			String string = arrNames.get(i);
			System.out.println(string);
		}

Which one of the Above method is Faster?
All the methods are of same speed since the Traditional for loop uses Iterator inside.The performance difference is noted when there is change in data structure while doing random access like linkedlist is slower than arraylist when you use a traditional for loop since to traverse a 6th element in list it should start from all again

When there is a sorted Array and you should do a search in the sorted array then using BinarySearch is faster than Linear Search