2009 July | DeepakGaikwad.net
Home » Archive

Articles Archive for July 2009

Java, Tech Notes »

[20 Jul 2009 | No Comment | ]

Annotation is not a new feature getting introduced in Java 5, but in this release Java is trying to explore the power of this feature. If we look at the open source product stack adapting to Java 5, then this is the feature what has changed most of the products considerably. It has begun a new era of decorative programming. In this article, it is assumed that you already have knowledge of Java, and can appreciate this article focusing on the concept of annotations, use of annotations etc.
Annotations Prior to …

Headline »

[16 Jul 2009 | No Comment | ]

Before going into what Java is offering in this new release, let us understand what dynamically typed languages are. Examples are Javascript, Ruby, Python, Groovy and so on. Few details of these languages -

Common feature is an ability to modify classes at runtime to allow implementation of new interfaces. The name is dynamically typed language because it is possible to determine the type at runtime. E.g. in Javascript we declare a var abc. This can contain String, int, or any other type of value. While using this value we …

Java, Tech Notes »

[10 Jul 2009 | No Comment | ]

Static keyword is used to allow access to an attribute/ a method or a class without creating instance of it. (Some of you may argue that this is not object oriented way, but we leave that discussion aside for now.) We use static for those elements which do not change from instance to instance of a class. An example would be constant variables in a program. These values are stored using ‘public static final’ keywords. In enum article we have seen one way of managing logically linked constants. Static import …

Java, Tech Notes »

[9 Jul 2009 | One Comment | ]

Varargs means variable arguments, something really different from normal Java language syntax. Normally, we define method signature to offer a contract to the callers of that method by restricting number and type of input parameters, return data type and exceptions thrown. Using vararg feature, we can overcome this restriction partially and make the signature dynamic. You may say that the dynamic signature is not new. Following two options you used many times to avoid an impact on clients due to additional/reduced parameters in signatures.

Using array/collection as an input parameter

Java, Tech Notes »

[8 Jul 2009 | 18 Comments | ]

Enumerations already existed in other languages like C, C++, SmallTalk etc. Enums are used primarily to handle a collection of logically grouped constants. In Java, for ages we have been handling constants (number constants here) through separate Java files, sometimes by encapsulating those in relevant POJOs, and even using a wrong design style of implementing an interface containing all constants. We used these constants in conditions implemented using ‘if’ statement or switch cases also. First thing you can notice about all these approaches is that this made the code look …