Thursday, July 30, 2009

The case against checked exceptions

For a number of years now I have been unable to get a decent answer to the following question: why are some developers so against checked exceptions. I have had numerous conversations, read things on blog, read what Bruce Eckel had to say (the first person I saw speak out against them).
I am currently writing some new code and paying very careful attention to how I deal with exceptions. I am trying to see the point of view of the "we don't like checked exceptions" crowd and I still cannot see it.
Every conversation I have ends with the same question going unanswered... let me set it up:
In general (from how Java was designed),
Error is for things that should never be caught (VM has a peanut allergy and someone dropped a jar of peanuts on it)
RuntimeException is for things that the programmer did wrong (programmer walked off the end of an array)
Exception (except RuntimeException) is for things that are out of the programmers control (disk fills up while writing to the file system, file handle limit for the process has been reached and you cannot open any more files)
Throwable is simply the parent of all of the exception types.
A common argument I hear is that if an exception happens then all the developer is going to do is exit the program.
Another common argument I hear is that checked exceptions make it harder to refactor code.
For the "all I am going to do is exit" argument I say that even if you are exiting you need to display a reasonable error message. If you are just punting on handling errors then your users won't be overly happy when the program exits without a clear indication of why.
For the "it makes it hard to refactor" crowd, that indicates that the proper level of abstraction wasn't chosen. Rather than declare a method throws an IOException, the IOException should be transformed into an exception that is more suited for what is going on.
I don't have an issue with wrapping Main with catch(Exception) (or in some cases catch(Throwable) to ensure that the program can exit gracefully - but I always catch the specific exceptions I need to. Doing that allows me to, at the very least, display an appropriate error message.
The question that people never reply to is this:
If you throw RuntimException subclasses instead of Exception subclasses then how do you know what you are supposed to catch?
If the answer is catch Exception then you are also dealing with programmer errors the same way as system exceptions. That seems wrong to me.
If you catch Throwable then you are treating system exceptions and VM errors (and the like) the same way. That seems wrong to me.
If the answer is that you catch only the exceptions you know are thrown then how do you know what ones are thrown? What happens when programmer X throws a new exception and forgot to catch it? That seems very dangerous to me.
I would say that a program that displays a stack trace is wrong. Do people who don't like checked exceptions not feel that way?
So, if you don't like checked exceptions can you explain why not AND answer the question that doesn't get answered please?
Edit: I am not looking for advice on when to use either model, what I am looking for is why people extend from RuntimeException because the don't like extending from Exception and/or why they catch an exception and then rethrow a RuntimeException rather then add throws to their method. I want to understand the motivation for disliking checked exceptions.
More details please refer - http://stackoverflow.com/questions/613954/the-case-against-checked-exceptions

HTTP vs HTTPS performance

Are there any major differences in performance between http and https? I seem to recall reading that https can be up to 1/5 times slower than http. Is this valid with the current generation webservers/browsers? If so, are there any whitepapers to support it?
For more details pl visit this site - http://stackoverflow.com/questions/149274/http-vs-https-performance

Wednesday, July 29, 2009

A Preview of GWT 2.0

Google Web Toolkit (GWT) is an open source set of tools that allows web developers to create and maintain complex JavaScript front-end applications in Java. It is licensed under the Apache License version 2.0. The GWT’s mission statement focuses on radically improving the web experience for users, by enabling developers to use existing Java tools to build no-compromise AJAX for any modern browser.
Google is set to launch GWT 2.0 later this year. The progress of GWT has been slow but steady over the years. Let us explore the road traveled so far and what lies ahead
The miles travelled…
Google promises much more with the GWT2.0 version scheduled to release later this year. Its various versions have been made available in the following sequence, with 2.0 following…
GWT 1.0 May 17, 2006
GWT 1.1 August 11, 2006
GWT 1.2 November 16, 2006
GWT 1.3 February 5, 2007
GWT 1.4 August 28, 2007
GWT 1.5 August 27, 2008
GWT 1.6 April 07, 2009
GWT 1.7 July 13, 2009
The launch…
And in comes the GWT 2.0 scheduled to be launched later this year. There is a lot on offer for this new version as Google promises to improvise it. GWT 2.0 contains huge improvements, including dynamic script loading, a new catalog of compiler optimizations, and a new approach to hosted mode debugging that uses the native browser.
The hosted mode is a key to productive development and it helps in debugging, editing etc. The problem is that the hosted mode browser is too special e.g. on Linux, hosted browser is an ancient Mozilla, hard to simulate interactions with other technologies (e.g. Flash) and it is impossible to debug browsers on non-dev OSes (e.g. IE from Mac). The GWT solves these problems by making hosted mode work with most native browser and make it work across the network.
Another huge advantage will be the compiler enhancements that come with the new kit. This new version promises much faster compilations, size, speed and obscurity benefits.
A new feature is the developer-guided code splitting. Often the compiled script size can be a problem because it holds all the code and can grow very big. Hence, the initial download can be too slow; UI hangs during script parsing etc. GWT 2.0 provides a solution, in code splitting by using- runasync. It is intentionally developer-guided and async. It intentionally forces you to think about failure paths. The split point doesn’t necessarily split. The compiler decides how to cluster code and it is guaranteed to be correct, ordering-wise.
Another new feature is the ClientBundle which generalizes ImageBundle to arbitrary resource types. With ClientBundle not only images are bundled together, all the resources (like CSS) are getting bundled. The obvious advantage is that only one file has to be downloaded, hence, less HTTP requests and faster download. Additionally, resources like CSS are getting optimized for size. At the Google I/O presentations it was also mentioned that in later versions ClientBundle probably also handles binary resources using Base64.
In GWT 2.0 there is the possibility to create a RPC blacklists which tell the RPC subsystem to skip types that you know aren’t ever sent across the wire and so doesn’t get compiled and stuffed into the code base. GWT 2.0 also promises a faster, easier and more predictable layout (at last). The standards mode provides new leverage including constraint-based layout that actually does what you say and also you’ll never have to hook the window resize event again. There is an updated set of Panels in GWT 2.0.
Version 2.0 will bring GWT a huge step forward and boost performance for developers and clients. It is not official, but 2.0 maybe also brings a new XML based markup language to define the layout. My guess is that the syntax will be close to HTML. Let’s hope that the new version attracts more GWT developers and which hopefully results in more widget libraries and extensions.

For more details please visit http://www.hemju.com/2009/07/24/a-preview-of-gwt-2-0/

Tuesday, July 28, 2009

Debunking Performance Myths: Java Vs C / C++

For all those who have passionately argued over performance and memory management aspects of Java and C++, an interesting article discussing some modern JVM features that significantly improve performance of Java applications.

For more details pl visit this site - http://www-128.ibm.com/developerworks/java/library/j-jtp09275.html?ca=dgr-jw22JavaUrbanLegends

Only in Pune

If you know some one staying in Pune (India) let them know this. If you are in Pune, do go through this story COZ, its a real one. Read this true story…and let everybody you know in and around Pune especially University Road……….

My friend lives in Deccan… One day he went to University Road to visit his uncle for some days as his parents had to attend a wedding in Lonavla. One evening he and some other of my college friends went to Adlabs for a movie. He had so much fun that he forgot that it's very late. He caught the last PMT to University Road….. he reached University Road around midnight…… He had to walk about a mile from the bus stop to home…. As he was walking alone, he could sense that the night felt very creepy as it was so dark. While walking, he was astonished to see an old weird-looking guy selling some books. It was a very unusual thing to see a thing like that…..

It got the shivers ! on him when he noticed that his old guy was unusually pale and staring at him… The old guy said "Son why don't you buy a book…it would keep you company".

Then my friend did something which he would regret for the rest of his life. My friend started to act brave & thought why not & had a look at his collections. My friend's hair started to stand on end as he noticed that all the books were related to supernatural activities…but he found one that was very interesting.

So he asked the old man "how much is it, uncle?" The old guy replied, "Well son…this is an interesting book…it's only for Rs 250.

My friend was shocked and said "but…but… it's expensive"

This time the old man stared which freaked my friend. My friend did not want to cross this scary old man, so he quickly checked all his pockets & found Rs.200 & said "This is all I have." The old guy replied "It's OK son… you can have the book for that price"

As my friend was just about to run for home…the old man called back & said "Son … whatever happens, don't ever flip the book to it's last page… remember these words or you will regret…!!!!!"

My friend nodded and never looked back … Reaching home…he quickly asked his Uncle whether there was any new old book seller nearby? The Uncle replied " I haven't seen him but ….we've heard that there's 1 old man who comes once in a while during full moon nights but heard that there is something creepy about it…why son?"

My friend freaked out… he told his uncle "nothing uncle… just asking". He started reading the book with the old man's parting words on his mind…At night, 2 o'clock, as he went to bed, a gush of wind blew which
chilled him up to his bones. At that point, he noticed the wind had blown th e pages to its last page. He remembered what the old man has said! But we humans tend to have the tendency to know. Out of curiosity, he flipped to the last page & fainted… What he saw at the last page is stated below:

Don't look further down if you have a weak heart I warn you

…………

…..

…..

…..

….

…..

….

….

….

….

….

….

….

…..

….

….

….

….

….

….

….

…..

….

…..

…..

…..


….

….

….

…..

….

….

…..

…..

…..

…..

….

…..

….

….

….

….

….

….

….

…..

….

….

….

….

….

….

….

…..

….

…..

…..

…..


….

….

….

…..

….

….

…..

Original price:– Rs. 20/-

Promotion price:– Rs. 10/-

Interviewing Java Developers With Tears in My Eyes

During the last week I had to interview five developers for a position that required the following skills: Flex, Java, Spring, and Hibernate. Most of these guys had demonstrated the 3 out of 10 level of Flex skills even though each of them claimed a practical experience on at least two projects. But this didn’t surprise me – Flex is still pretty new and there is only a small number of developers on the market who can really get Flex things done.
What surprised me the most is a low level of Java skills of most of these people. They have 5-8 years of Java EE projects behind their belts, but they were not Java developers. They were species that I can call Robot-Configurator. Each of them knew how to configure XML files for Spring, they knew how to hook up Spring and Hibernate and how to map a Java class to a database entity. Some of them even knew how to configure lazy loading in Hibernate even though not all understood why it’s needed.
Two out of five developers who claimed seniority in Java proved to have a mid-level understanding of this programming language. The other three really disappointed me. They didn’t even know the basics of Java…One of them had no idea of what interfaces are for. The other one was still killing a thread by calling a deprecated ten years ago method stop(), the third guy had issues explaining the data flow of a standard Web application built with Servlets and JDBC.

Next time you’ll be interviewing a Java guru, ask him/her the following question, “There is an HTML form with a button Submit, a servlet and a relational database with the table Customers. The users enters a First and Last names of the customer, presses the button Submit, and you need to write the code that would return the detailed data about this customer. Explain IN DETAILS the entire data flow and the HTML/Java processing you’d need to perform.”
Do not forget to repeat that the candidate is not allowed to use neither Spring, nor Hibernate. You might be surprised... I like Java, and it’s sad to see these herds of creatures who truly believe that they are Java developers. They aren’t.

For more details pl visit this site - http://java.sys-con.com/node/1040135

Java theory and practice: Concurrency made simple (sort of)

Like many other application infrastructure services, concurrency utility classes such as work queues and thread pools are often needlessly rewritten from scratch for every project. This month, Brian Goetz offers an introduction to Doug Lea's util.concurrent package, a high-quality, widely used, open-source package of concurrency utilities.

The util.concurrent package contains many useful classes, some of which you may recognize as better versions of classes you've already written, perhaps even more than once. They are battle-tested, high-performance implementations of many of the basic building blocks of multithreaded applications. util.concurrent was the starting point for JSR 166, which will be producing a set of concurrency utilities that will become the java.util.concurrent package in JDK 1.5, but you don't have to wait until then. In a future article, I'll look at some of the custom synchronization classes in util.concurrent, and explore some of the ways in which the util.concurrent and java.util.concurrent APIs differ.

More details visit this link: http://www.ibm.com/developerworks/java/library/j-jtp1126.html

Monday, July 27, 2009

***Key to Abbreviations

Lat: Site latitude (degrees)
Long: Site longitude (degrees)
AZm: Magnetic azimuth or compass bearing (degrees)
AZ: True azimuth (degrees)
EL: Elevation (degrees)
ELp: Polar elevation (degrees)
ELa: Apex elevation (degrees)
PO: Polarization offset (degrees)

Do not turn on A/C immediately as soon as you enter the car!

I received this circular from Tata Motors Ltd., please read carefully & pass-it on to others.

Please open the windows after you enter your car and do not turn ON the
air-conditioning immediately. According to a research done, the car dashboard,
sofa, air freshener emits Benzene, a Cancer causing toxin (carcinogen- take note
of the heated plastic smell in your car). In addition to causing cancer, it poisons
your bones, causes anemia, and reduces white blood cells. Prolonged exposure
will cause Leukemia, increasing the risk of cancer may also cause miscarriage.

Acceptable Benzene level indoors is 50 mg per sq. ft. A car parked indoors with
the windows closed will contain 400-800 mg of Benzene. If parked outdoors
under the sun at a temperature above 60 degrees F, the Benzene level goes up
to 2000-4000 mg, 40 times the acceptable level... & the people inside the car will
inevitably inhale an excess amount of the toxins.
It is recommended that you open the windows and door to give time for
the interior to air out before you enter. Benzene is a toxin that affects your kidney and liver, and is very difficult for your body to expel this toxic stuff.

THE POWER OF POSITIVE TALK By the GREAT Dr. ABDUL KALAM


THE POWER OF POSITIVE TALK-

By the GREAT Dr. ABDUL KALAM


My older cousin, Tammy, was also in the same tree. She was hanging on the first big limb, about ten feet below me. Tammy's mother also noticed us at the exact time my dad did. About that time a huge gust of wind came over the tree. I could hear the leaves start to rattle and the tree begin to sway. I remember my dad's voice over the wind yell, "Bart, Hold on tightly." So I did. The next thing I know, I heard Tammy screaming at the top of her lungs, laying flat on the ground. She had fallen out of the tree.
I scampered down the tree to safety. My dad later told me why she fell and I did not. Apparently, when Tammy's mother felt the gust of wind, she yelled out, "Tammy, don't fall!" And Tammy did. fall.


My dad then explained to me that the mind has a very difficult time processing a negative image. In fact, people who rely on internal pictures cannot see a negative at all. In order for Tammy to process the command of not falling, her nine-year-old brain had to first imagine falling, then try to tell the brain not to do what it just imagined. Whereas, my eight-year-old brain instantly had an internal image of me hanging on tightly.
This concept is especially useful when you are attempting to break a habit or set a goal. You can't visualize not doing something. The only way to properly visualize not doing something is to actually find a word for what you want to do and visualize that. For example, when I was thirteen years old, I played for my junior high school football team. I tried so hard to be good, but I just couldn't get it together at that age. I remember hearing the words run through my head as I was running out for a pass, "Don't drop it!" Naturally, I dropped the ball.


My coaches were not skilled enough to teach us proper "self-talk." They just thought some kids could catch and others couldn't. I'll never make it pro, but I'm now a pretty good Sunday afternoon football player, because all my internal dialogue is positive and encourages me to win. I wish my dad had coached me playing football instead of just climbing trees. I might have had a longer football career.

Here is a very easy demonstration to teach your kids and your friends the power of a toxic vocabulary. Ask them to hold a pen or pencil. Hand it to them. Now, follow my instructions carefully. Say to them, "Okay, try to drop the pencil." Observe what they do.
Most people release their hands and watch the pencil hit the floor. You respond, "You weren't paying attention. I said TRY to drop the pencil. Now please do it again." Most people then pick up the pencil and pretend to be in excruciating pain while their hand tries but fails to drop the pencil.

The point is made.
If you tell your brain you will "give it a try," you are actually telling your brain to fail. I have a "no try" rule in my house and with everyone I interact with. Either people will do it or they won't. Either they will be at the party or they won't. I'm brutal when people attempt to lie to me by using the word try. Do they think I don't know they are really telegraphing to the world they have no intention of doing it but they want me to give them brownie points for pretended effort? You will never hear the words "I'll try" come out of my mouth unless I'm teaching this concept in a seminar.

If you "try" and do something, your unconscious mind has permission not to succeed. If I truly can't make a decision I will tell the truth. "Sorry John. I'm not sure if I will be at your party or not. I've got an outstanding commitment. If that falls through, I will be here. Otherwise, I will not. Thanks for the invite."
People respect honesty. So remove the word "try" from your vocabulary.

My dad also told me that psychologists claim it takes seventeen positive statements to offset one negative statement. I have no idea if it is true, but the logic holds true. It might take up to seventeen compliments to offset the emotional damage of one harsh criticism.
These are concepts that are especially useful when raising children.


Click here to join nidokidos

Ask yourself how many compliments you give yourself daily versus how many criticisms. Heck, I know you are talking to yourself all day long. We all have internal voices that give us direction.
So, are you giving yourself the 17:1 ratio or are you shortchanging yourself with toxic self-talk like, " I'm fat. Nobody will like me. I'll try this diet. I'm not good enough. I'm so stupid. I'm broke, etc. etc."
If our parents can set a lifetime of programming with one wrong statement, imagine the kind of programming you are doing on a daily basis with your own internal dialogue.
Here is a list of Toxic Vocabulary words.
Notice when you or other people use them.
Ø But: Negates any words that are stated before it.
Ø Try: Presupposes failure.
Ø If: Presupposes that you may not.
Ø Might: It does nothing definite. It leaves options for your listener..
Ø Would Have: Past tense that draws attention to things that didn't actually happen.
Ø Should Have: Past tense that draws attention to things that didn't actually happen (and implies guilt.)
Ø Could Have: Past tense that draws attention to things that didn't actually happen but the person tries to take credit as if it did happen.
Ø Can't/Don't: These words force the listener to focus on exactly the opposite of what you want. This is a classic mistake that parents and coaches make without knowing the damage of this linguistic error.

Examples:
Toxic phrase: "Don't drop the ball!"
Likely result: Drops the ball
Better language: "Catch the ball!"

Toxic phrase: "You shouldn't watch so much television."
Likely result: Watches more television.
Better language: "I read too much television makes people stupid. You might find yourself turning that TV off and picking up one of those books more often!"

Exercise:
Take a moment to write down all the phrases you use on a daily basis or any Toxic self-talk that you have noticed yourself using. Write these phrases down so you will begin to catch yourself as they occur and change them.


Click here to join nidokidos


Agile Project Manager

Staying competitive in today’s economy means companies must deliver the right products to market faster than ever before. Agile methodologies are leading the way by helping software teams deliver products more frequently and with significantly higher quality. Making the switch to Agile practices challenges our traditional notions of software engineering best practices, project management methodologies and team leadership styles. The Agile approach impacts every role on a project team differently and creates opportunities to learn new skills and new ways of working together.

Shifting toward Agile methodologies has a particularly significant impact on the Project Management community. Agile introduces an entirely new framework for planning projects and introduces new ways of managing time, cost and scope. Agile challenges the Project Manager’s assumptions about certainty and encourages them to embrace change and manage risk through the delivery of working software. Collaboration, facilitation, servant-style leadership, coaching and team building become significant new skills that will help the Project Manager effectively lead Agile teams.

This white paper will explore the impact agile development methodologies are having on the Project Management community, what new skills are required, and what the Project Manager can do to ease the transition.

Tasty Khana

This site helps you have the right food at (or from) the right place. To get this done we tie-up with the premium restaurants in Pune and look to provide end-to-end solutions. Find rocking party places at the best prices