July 28, 2011

Java 1.7

I have been reading quite a lot about Java 1.7. There are articles about what's new, some code examples, some benchmark to compare performance with previous version of Java and discussion on when it will be released. I have decided to regroup all I have discovered in this article so that I and maybe you, won't have to spend hours surfing the web to find all this information. Don't hesitate to leave a comment if I missed something.
What's new in Java 1.7?

So what made it through is the following:
§ Strings in switch
§ Automatic Resource Management
§ Improved Type Inference for Generic Instance Creation (diamond)
§ Simplified Varargs Method Invocation
§ An omnibus proposal for better integral literals
§ Language support for Collections
§ Language support for JSR 292

These features are divided in different categories:

§ Compressed 64-bit object pointers
§ Garbage-First GC (G1)
§ JSR 292: VM support for non-Java languages (InvokeDynamic)

§ SR 294: Language and VM support for modular programming
§ JSR 308: Annotations on Java types
§ JSR TBD: Small language enhancements (the Project Coin I was talking about)
§ JSR TBD: Project Lambda

§ Modularization (Project Jigsaw)
§ Upgrade class-loader architecture
§ Method to close a URLClassLoader
§ Unicode 5.1
§ Concurrency and collections updates (jsr166y)
§ JSR 203: More new I/O APIs for the Java platform (NIO.2)
§ SCTP (Stream Control Transmission Protocol)
§ SDP (Sockets Direct Protocol)
§ Elliptic-curve cryptography (ECC)

§ XRender pipeline for Java 2D
§ Forward-port 6u10 deployment features
§ Create new platform APIs for 6u10 graphics features
§ Nimbus look-and-feel for Swing
§ Swing JLayer component

§ Update the XML stack
As you can see there is a lot of stuff. I personally tried the new Garbage Collector (G1) a few months back and was really impressed by the performance. Unfortunately the JVM was crashing every few hours so it couldn't be used for production. This GC is available in Java 1.6 as well but same thing, it crashes every so often.
I think that's it for the new features. Maybe it's a good idea to see some code examples now.

July 23, 2011

Dependency Injection

Java components / classes should be as independent as possible of other Java classes. This increases the possibility to reuse these classes and to test them independently of other classes(Unit Testing). To decouple Java components from other Java components the dependency to a certain other class should get injected into them rather that the class itself creates / finds this object.

A class A has a dependency to class B if class uses class B as a variable.

If dependency injection is used then the class B is given to class A via

the constructor of the class A - this is then called construction injection

a setter - this is then called setter injection

The general concept between dependency injection is called Inversion of Control. A class should not configure itself but should be configured from outside.

A design based on independent classes / components increases the re-usability and possibility to test the software. For example if a class A expects a Dao (Data Access object) for receiving the data from a database you can easily create another test object which mocks the database connection and inject this object into A to test A without having an actual database connection.

A software design based on dependency injection is possible with standard Java.

July 20, 2011

Google+ Approaches 18 Million Users

Google+ continues to set records as the fastest-growing social network in history, but Google’s social juggernaut is beginning to show signs that it’s losing steam.

Ancestry.com co-founder Paul Allen (not to be confused with the Microsoft co-founder of the same name) posted his most recent analysis of Google+’s growth on his Google+ account Tuesday. According to his analysis, the search giant’s Facebook competitor will likely reach 18 million users by the end of Tuesday, but its growth rate has dropped by 50% from its peak.

“Last week we saw two days where more than 2 million signed up in a single day,” Allen said in his post. “If that rate had continued, Google+ would have reached 20 million users by last Sunday night. But the last four days have averaged only 948,000 new users, and yesterday the site added only 763,000. Yesterday’s growth of 4.47% was the slowest viral growth since Google opened up invites back on July 6.”

Why is Google+’s growth slowing down? Google Trends indicates that the buzz around Google+ has died down some, which is natural for any major news item. Allen makes the important point that Google+ hasn’t been promoted by any of its other properties and that the social network is still invite-only. Once Google+ is promoted on YouTube or on Google.com, its growth may simply skyrocket.

Allen estimated that Google+ hit the 10 million user mark sometime on July 12 or 13. Google CEO Larry Page confirmed that Google+ had more than 10 million users during an investor earnings call on July 14. Its most followed user, Mark Zuckerberg, now has more than 250,000 followers, despite not posting a single public item on his Google+ account.

July 19, 2011

Review on Golfakademie

Golf Platzreife means "Complete and utter load of bollocks" in English and I will tell you why.

The idea behind it is that you answer a few questions about golf rules and then play a few holes of golf with your instructor. As long as you do not kill too many people whilst playing then you get your 54 handicap... Seriously.. 54 handicap. Basically a 54 handicap means you cannot actually play golf at all and should not really be allowed on a half-decent golf course... But everybody must start somewhere I suppose.....

Since many people are interested in learning the game, there are many golf academies newly erecting in and around the city. Golf academies bear the responsibility to teach the young generation about the game. The rules of the golf etiquette are the first and fore most things, the golf academies teach their students. The rules of the game mainly aim at the safety of the golfers and to the pace of the play, which helps in keeping the game enjoyable. The golf etiquette is an essential part of the game. This is something very vital that all the new comers and the new beginners should learn on the course.

For any game to be played successfully, the instruments used for the play should be manufactured or prepared with utmost care and you can found all these instruments at their Golf shop. A standard set of a golf club mainly consists of three woods, eight irons and a putter. Actually according to the rules and regulations of the play a golfer is allowed to carry 14 clubs in the bag. The more clubs the player carries the easier is his victory. To know more about golf academies, please visit Golfreisen.
The above site explains you all the details about the game. They are one of the largest German golf shops with a full range of all brand names. You can also visit Golfkurse it will be useful for you.

July 13, 2011

Importing a class from default package - Impossible

Did you know that classes in the ‘default package’ (classes that don’t have a package) cannot be imported from classes that do have a package?

I did not know that.

Try it:

Now try to compile your code:
>javac Class1.java

>javac package2\Clazz2.java -cp .

package2\Clazz2.java:3: ‘.’ expected
import Class1;
package2\Clazz2.java:3: ‘;’ expected
import Class1;

How stupid is this?
Is this why omitting package is deprecated?

Copyright 2007 All Right Reserved. shine-on design by Nurudin Jauhari. and Published on Free Templates