My take on Java 7 features

JDK 1.7 Features

JDK 1.7 Features

No wonder the features look quite impressive indeed. Use of “String” in switch statement was long due! 🙂

InvokeDynamic is also a very useful feature. I have been using C# for quite some time and InvokeDynamic has certainly saved lot of time and improved readability of the code.

1) var foo = new List<int>();
2) List<int> foo = new List<int>();
First statement looks much cleaner. Let’s look at a more complex scenario:
List<Map<int,string>> foo = new List<Map<int,string>>();    //InvokeDynamic is highly recommended without a doubt!

TLS and Swing improvements are welcome! New IO API is welcome as well.

According to what I’ve read they’ve decided to improve the release schedule to get the product out quicker. This is why some features were dropped from the 7 release. Shortly after the release, Java team will release 7.1 with some of those dropped features. I did not think 7 was ever going to be released since they were playing around with closure proposals rather than looking at what is already in existence.

I am really interested in closures. The “automatic resource management” has been in C# since the very beginning. Every C# dev is familiar with the “using” statement. Now, why would Java choose the weird-looking syntax of “try {}” instead of “using {}”? Strange!

0  

I love you, Google!

I love you, Google

I love you, Google

That’s just Google propagating the most popular link on that page and providing easier access to it, as opposed to intelligently realizing it’s an intro page and providing a way to skip it. Interesting concept! Now I am looking for an option to make this the default behavior! 😛

0  

Possible Concurrency solution in n-tier Web Applications

Concurrency is one of the major issues during development of n-tier Web Applications since Client-side & Server-side work independently.

Concurrency is typically handled on the Server-side. We can either keep a version number or maintain a timestamp for every record.

  • Handle Concurrency by maintaining a timestamp (Shown visually below)
Possible Concurrency solution in n-tier Web Applications

Possible Concurrency solution in n-tier Web Applications

  • Handle Concurrency by maintaining a version number

Every time a record is updated in database, version number is incremented. We send the version number from client to server and vice-versa. Before updating on server we check if the version number in Database is greater than the one from client. If yes, it means somebody has already updated the record and we simply, show appropriate warning message. No update operation is allowed whatsoever.

0  

Ping program in Java to determine the “network throughput”

I had to determine the “network throughput” from a server to another server. Idea is to use the ping command  to get the information. The ping can send the data multiple times and at the end of the process, give the average time it took to process.

The expected output is displayed below in blue color which has the average time and capture the number.

Below is the example.

C:\>ping www.yahoo.com -n 2 -l 210

Pinging any-fp.wa1.b.yahoo.com [67.195.160.76] with 210 bytes of data:

Reply from 67.195.160.76: bytes=210 time=56ms TTL=51
Reply from 67.195.160.76: bytes=210 time=78ms TTL=51

Ping statistics for 67.195.160.76:
Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:

Minimum = 56ms, Maximum = 78ms, Average = 67ms

Here is my pseudo code >>

– Run the program from the server. It is checking throughput to the server mentioned in args[1]
– Need 2 arguments 1) URI of the server  2) Interval 3) data packet to transfer in bytes
– Run a Ping command  args[0] -n args [1] -l args[2]
– Parse the results and get the average time taken
– Throughput (KB/s) is =  ( args[2] * 1000000 /(Avg))/1024
– Because avg is in ms; use 1024 to convert the Throughput to KB/sec

Source File: Ping.java
(Replace the “.java_.txt” extension to “.java” before using the file)

0  

What does Google love? :)

What does Google love?

What does Google love?

0