Link code change list and issue with FishEye and JIRA 关联代码变更与Issue/BacklogItem

Categories: Java; Tagged with: ; @ June 17th, 2012 11:49

Tester report a bug, and assign to you, you coding, and commit changes, and then you go back to the bug,  wright some comments, maybe include your changelistID, then resolve the issue.

How can someone else know what’s you have done for this issue? how can you find the related code changes quickly?

FishEye can help we do this!

How FishEye can Help

FishEye opens up your repository, helping you to understand your changing source code:

  • Track changes to your own, your team’s, or everyone’s source code.
  • Choose to be notified by email and/or RSS feeds.
  • View the configurable changelog.
  • Use the powerful search functionality
  • Construct your own sophisticated queries with EyeQL and integrate the results with other tools using the FishEye API.
  • Link to any artifact in your repository: commits, diffs, directories, file histories, revisions, source lines, and search results.
  • Analyse your repository with:
    • Line graphs at every node from root to revision.
    • ‘Related Revisions’, a list of modifications from all branches, sorted by revision number.
    • File annotations for age and ownership.

And it can work perfectly with JIRA, I’ll show you the perfect feature JIRA and FishEye work seamlessly:

  1. Create a new FishEye project, you need name it and input a ‘Key’;
  2. Link this project with the JIRA project by input a JIRA project key. (or we can link project in JIRA by input a FishEye project key).
  3. Edit ‘FishEye Content’ after the creation complet: we need to config the repository path for the project.
  4. Commit some code to the repository paht, then go to the project page:
    image
    And we can view this change details:
    image
    It’s cool, right? but It can be more interesting.
  5. Someday, tester report an issue, say any one can login, the tester create a new issue in JIRA:
    image

    This bug was assigned to me.

  6. I fix this bug, and commit code change:
    image
    I want to record this change in JIRA, so that anyone concern can track my work.
    How can JIRA know which issue I’m working on?
    Here is a convention:
    use the issue id as the beginning of the comment, I commit the changes, and JIRA will capture this change list, and link to the issue: SPRIN-10.
  7. And now return to the issue page, the commit I just did has been added to the issue! Wow, that’s really cool!
    image
    We can see all related change, really helpful, not only for management, but also for developers.

Manage Agile development using JIRA 使用JIRA管理敏捷项目

Categories: Development Notes; Tagged with: ; @ June 17th, 2012 1:43

“Welcome to JIRA — the easy way to help your team track and deliver projects.”

It’s more than a bug track platform, it also can  plan agile development, monitor activity, report on project status,.

1. Create a new story: issues>Create issue:
we can specify the affect/fixed version, and assign the issue to some member, and give a estimate time.

2.  then the ‘Assignee’ can start the process, and  log our work.

image

3. In the Agile>ChartBoard, we can see Hour/Issue burndown chart,:

image

4.  We can manage rapid board configuration, schedule sprint planning:

image

Drag&Drop is a cool feature, and then we can see a summary of the Sprint:

image

you can see reports like burndown chart by clicking ‘Report’ in the top right.

Using Inner class in Java

Categories: Java; Tagged with: ; @ May 22nd, 2012 1:03

Here is the code:

package innerClasds.scjp.liguoliang.com;

import java.io.Serializable;

public class TestInnerClass {
	
	private String name = "var+TestName";
	
	public static void main(String[] args) {
		new TestInnerClass().new InnerClass().printDes();
		new TestInnerClass().testInnerClassInMethod("info");
		TestInnerClass.StaticClass.printInfo();
	}

	/**
	 * 2. Inner class in method.
	 */
	void testInnerClassInMethod(final String info) {
		// In this class, we can get any variable in the outer class, but only can access the final variables in the method.
		// The reason is(from scjp book): can not keep variables(stored in stack) can keep as long as  inner class instance (stored in the heap),
		// so the inner class only access the final variable. 
		
		// and the class access modifier:  only abstract or final is permitted
		abstract class InnerClassInMethod {
			abstract void printInfo();
		}
		
		/** 3. Anonymous class;  */
		InnerClassInMethod inMethod = new InnerClassInMethod() {
			void printInfo() {
				System.out.println(InnerClassInMethod.class + TestInnerClass.this.name + "__" + info);
			}
		};
		
		inMethod.printInfo();
	}
	
	
	/**
	 * 1. Normal inner class. can use public, protected, (default), private accessor modifier to control the scope of the class.
	 * @author Li Guoliang
	 *
	 */
	private class InnerClass extends TestInnerClass implements Serializable{
		private static final long serialVersionUID = 1L;
		//always need final, otherwise: 
		//  The field s cannot be declared static; static fields can only be declared in static or top level types
		public static final String s = "s"; 
		void printDes() {
			System.out.println("Inner" + s + " " + TestInnerClass.class);
		}
	}
	
	/**
	 * 4. Static nested class.
	 * @author Li Guoliang
	 *
	 */
	private static class StaticClass {
		static void printInfo() {
			System.out.println(StaticClass.class);
		}
	}

}

Some comments:

1. Inner Class:

can be public, protected, private, final, abstract, static, strictfp.
need an outer instance to crate the inner instance, like: new TestInnerClass().new InnerClass();
Use outClass.this to get the outer instance;

2. Inner class in method

can be public, protected, private, final, abstract, static, strictfp;
can access any property in the outer instance;
only can access final variable in the method.

3. Anonymous class

4. Static nested class
can be public, protected, private, final, abstract, static, strictfp.

here are some notes when I first learn inner class in java: >>go<<

Java: Using Assertion in Eclipse

Categories: Java; Tagged with: ; @ May 21st, 2012 0:06

Assertion:

	public static void main(String[] args) {
		int x = 10;
		assert x==100:"assertion failed!";
	}

How to determine assertion is enabled or not?

		   boolean isEnable=false;
		   assert isEnable = true;
		   if(isEnable){
		       throw new RuntimeException("Assertion shoule be enable!");
		   }

This is a bad assertion, because it change the value, If assertion is enabled, isEnable will be set to true.

How to enable assertion in Eclipse?

Debug/Run configurations > VM arguments: add “-ea” to enable it or “-da” to disable assertion.

should not used for validate parameter in public method: because anyone can use public method, and can not make sure assertion is enabled or not;

About Exceptions in Java

Categories: Java; Tagged with: ; @ May 20th, 2012 17:22

Exceptions in Java:

                                      Object
                                     Throwable
                         Error                    Exception

                                           RuntimeException …..   

There are two types Exception:

1. Checked Exception , we need to declare ‘throws’ in mehtod if there maybe exception be  thrown out, and must be catch or throw it if we use the method.
2. UnChecked exception(RuntimeExcepiton), will be thorwed in runtime, no need to declare them in the method.

1. UnChecked Exception:

public class TestException {
	public void test() throws NullPointerException{
		System.out.println("Test  OK");
	}
	
	public static void main(String[] args) {
		new TestException().test();
	}
}

output: “Test OK”

2. Checked Exception:

public class TestException {
	public void test() throws IOException{
		System.out.println("Test  OK");
	}
	
	public static void main(String[] args) {
		new TestException().test(); // Can not compile: surround with try/catch or add throws declaration
	}
}

3. Overriding:

Access modifier can be enlarged, but exception only can be less or specialized.

package scjp.liguoliang.com;

import java.io.FileNotFoundException;
import java.io.IOException;

public class TestException {
	public void test() throws IOException{
		System.out.println();
	}

}

class TestExceptionSub extends TestException {
	public void test() throws FileNotFoundException{ // FileNotFoundException extends IOException
		
	}
}

This can work fine, but if we let TestExceptionSub to implement an Interface, like:

package scjp.liguoliang.com;

import java.sql.SQLException;

public interface ITestException {

	void test() throws  SQLException;
}
package scjp.liguoliang.com;

import java.io.FileNotFoundException;
import java.io.IOException;

public class TestException {
	public void test() throws IOException{
		System.out.println();
	}

}

class TestExceptionSub extends TestException implements ITestException{
	public void test() throws FileNotFoundException{ //Can not compile!
		
	}
}

Multiple markers at this line
    – overrides scjp.liguoliang.com.TestException.test
    – Exception FileNotFoundException is not compatible with throws clause in
     ITestException.test()

 

for test() in TestExceptionSub , If we want to throw any checked exception, we need get the sub class from ‘IOException’ and ‘SQLException’., or just remove throws declaration.

but for un-checked exception, you can throw any, and no matter with the super class declaration.

4. Catch sequence: the specification exception need catched before it’s super exception, otherwise:
“Unreachable catch block for Exception. It is already handled by the catch block for Throwable”

	public static void main(String[] args) {
		try{
			throw new SQLException();
		}catch (SQLException e) {
			System.out.println("SQLException catched!");
			return;
		}catch (Throwable e) {
			System.out.println("Exception Catched!");
			return;
		}
		finally {
			System.out.println("Finally");
		}
	}

Newer Posts <-> Older Posts



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.