- Some experience with java.
- Object-oriented programming concepts.
- Experience with using IDE like Eclipse, IntelliJ IDEA.
- Keep Updating the Android tools and Knowledge of Android capabilities.
Java Software Developer
This blog is for one who learn about java and open source tools. as a java developer i am writing my experience in this blog.
Thursday, June 20, 2013
YOU SHOULD KNOW TO LEARN ANDROID
If you want learn android quickly you should know
Android App Development.
It's been 3 months now started developing android apps. best way to learn is go with the official developer site training tutorials. it's free of cost after that go and play with the samples from that you can learn some fundamentals and you will know how to use the sdk effectively. one who having the java knowledge can learn easily.
Friday, December 14, 2012
Software Continuous Integration tool
Today am gone discussed about one of the Software Continuous Integration tool so far i used a lot of tools. one i recomend for continuous integration is CodePro Analytix. it was amazing tool. this product was developed by Google. it is very easy tool to work with an IDE just like eclipse. CodePro AnalytiX is a powerful software code quality, testing and static
analysis tool designed to help developers automatically improve
software quality, security, reliability and maintainability in Java
applications they develop.
Am going to discuss features of CodePro Analytix one by one.
Code Coverage
Powerful tools that measure what percentage of code is being executed using generated test cases or manual test scripts.
Dependency Analysis
Automated tools that analyze and visually depict the dependencies between projects, packages, and types
JUnit Test Editor
A rich JUnit test editing environment that enables rapid creation, organization, modification and execution of unit tests.
JUnit Test Generation
Time-saving facility that uses sophisticated flow path analysis techniques to automates the creation of comprehensive JUnit regression tests
Similar Code Analysis
Efficiently examines Java code to find duplicate or very similar segments of code containing copy/paste bugs or that can be refactored to improve application design and maintainability
Code Analysis
Dynamic, extensible tools that detect, report and repair deviations or non-compliance with predefined coding standards, popular frameworks, security and style conventions
Metrics
Automated tools that measure and report on key quality indicators in a body of Java source code
If you want to learn further you can simply google it. you will get the more information.
Am going to discuss features of CodePro Analytix one by one.
Code Coverage
Powerful tools that measure what percentage of code is being executed using generated test cases or manual test scripts.
Dependency Analysis
Automated tools that analyze and visually depict the dependencies between projects, packages, and types
JUnit Test Editor
A rich JUnit test editing environment that enables rapid creation, organization, modification and execution of unit tests.
JUnit Test Generation
Time-saving facility that uses sophisticated flow path analysis techniques to automates the creation of comprehensive JUnit regression tests
Similar Code Analysis
Efficiently examines Java code to find duplicate or very similar segments of code containing copy/paste bugs or that can be refactored to improve application design and maintainability
Code Analysis
Dynamic, extensible tools that detect, report and repair deviations or non-compliance with predefined coding standards, popular frameworks, security and style conventions
Metrics
Automated tools that measure and report on key quality indicators in a body of Java source code
If you want to learn further you can simply google it. you will get the more information.
Tuesday, August 16, 2011
Important points about Enum in Java
1) Enums in Java are type-safe and has there own name-space. It means your enum will have a type for example "Currency" in below example and you can not assign any value other than specied in Enum Constants.
public enum Currency {PENNY, NICKLE, DIME, QUARTER};
Currency coin = Currency.PENNY;
coin = 1; //compilation error
2) Enums in Java are reference type like class or interface and you can define constructor, methods and variables inside java enum whichmakes it more powerful than Enum in C and C++ as shwon in next example of java enum type.
3) You can specify values of enum constants at the creation time as shown in below example:
public enum Currency {PENNY(1), NICKLE(5), DIME(10), QUARTER(25)};
But for this to work you need to define a member varialbe and a constructor because PENNY (1) is actually calling a constructor which accepts int value , see below example.
public enum Currency {
PENNY(1), NICKLE(5), DIME(10), QUARTER(25);
private int value;
private Currency(int value) {
this.value = value;
}
};
Constructor of enum in java must be private any other access modifier will result in compilation error. Now to get the value associated with each coin you can define a public getValue () method inside java enum like any normal java class. Also semi colon in the first line is optional.
4) Enum constants are implicitly static and final and can not be changed once created. For example below code of java enum will result in compilation error:
Currency.PENNY = Currency.DIME;
The final field EnumExamples.Currency.PENNY cannot be re assigned.
5) Enum in java can be used as an argument on switch statment and with "case:" like int or char primitive type. This feature of java enum makes them very useful for switch operations. Let’s see an example of how to use java enum inside switch statement:
Currency usCoin = Currency.DIME;
switch (usCoin) {
case PENNY:
System.out.println("Penny coin");
break;
case NICKLE:
System.out.println("Nickle coin");
break;
case DIME:
System.out.println("Dime coin");
break;
case QUARTER:
System.out.println("Quarter coin");
}
6) Since constants defined inside enum in java are final you can safely compare them using "==" equality operator as shwon in following example of java enum:
Currency usCoin = Currency.DIME;
if(usCoin == Currency.DIME){
System.out.println("enum in java can be"+
"compared using ==");
}
7) Java compiler automatically generates static values () method for every enum in java. Values() method returns array of enum constants in the same order they have listed in enum and you can use values() to iterator over values of enums in java as shown in below example:
for(Currency coin: Currency.values()){
System.out.println("coin: " + coin);
}
And it will print:
coin: PENNY
coin: NICKLE
coin: DIME
coin: QUARTER
Notice the order its exactly same with defined order in enum.
8) In Java Enum can override methods also. Let’s see an example of overriding toString () method inside enum in java to provide meaningful description for enum constants.
public enum Currency {
........
@Override
public String toString() {
switch (this) {
case PENNY:
System.out.println("Penny: " + value);
break;
case NICKLE:
System.out.println("Nickle: " + value);
break;
case DIME:
System.out.println("Dime: " + value);
break;
case QUARTER:
System.out.println("Quarter: " + value);
}
return super.toString();
}
};
And here is how it looks like when displayed:
Currency usCoin = Currency.DIME;
System.out.println(usCoin);
output:
Dime: 10
9) Two new collection classes EnumMap and EnumSet are added into collection package to support java enums. These classes are high performance implementation of Map and Set interface in Java and we should use this whenever there is any opportunity.
10) You can not create instance of enums by using new operator in java because constructor of Enum in Java can only be private and Enum constants can only be created inside Enum itself.
11) Instance of enums in java is created when any enum constants are first called or refrenced in code.
12) Enum in Java can implement the interface and override any method like normal class It’s also worth noting that enum in java implicitly implement both Serializable and Comparable interface. Let's see and example of how to implement interface using java enum:
public enum Currency implements Runnable{
PENNY(1), NICKLE(5), DIME(10), QUARTER(25);
private int value;
............
@Override
public void run() {
System.out.println("Enum in Java implement interfaces");
}
}
13) You can define abstract methods inside enum in Java and can also provide different implementation for different instances of enum in java. Let’s see an example of using abstract method inside enum in java
public enum Currency implements Runnable{
PENNY(1) {
@Override
public String color() {
return "copper";
}
}, NICKLE(5) {
@Override
public String color() {
return "bronze";
}
}, DIME(10) {
@Override
public String color() {
return "silver";
}
}, QUARTER(25) {
@Override
public String color() {
return "silver";
}
};
private int value;
public abstract String color();
private Currency(int value) {
this.value = value;
}
..............
}
In this example since every coin will have different color we made the color () method abstract and let each instance of enum to define there own color. You can get color of any coin by just calling color () method as shown in below example of java enum:
System.out.println("Color: " + Currency.DIME.color());
That’s all on Java enums , Plesae share if you have any nice tips on enum in Java and let us know how you are using java enum in your work.
What Benefits of Enums in Java
1) Enum is type-safe you can not assign anything else other than predefined enum constant to an enum variable.
2) Enum has its own name-space.
3) Best feature of Enum is you can use Enum in Java inside Switch statement like int or char primitive data type.
4) Adding new constants on Enum in Java is easy and you can add new constants without breaking existing code.
Subscribe to:
Posts (Atom)