1. What is Generics: Generics is a feature in java language to create parameterized types. A parameterized type is a type with parameters passed to it, mostly to enable compiler to check for errors which otherwise would have been a runtime exception.
For example, let us consider programs below. In the first one, generics is not used. We are using java collection API to store and retrieve objects. In this program, it is impossible for the compiler to know what actually is stored in the collection. It is the programmer's job to take care that the objects stored are of expected type and that they are not cast to a wrong type in the time of retrieval. Not only this takes a lot of nasty boiler plate code, it also obfuscates the purpose of the collection all together. Generics attempts to solve this by passing parameters to type to specify what the types are related to. As we will see.
Saturday, July 30, 2011
Thursday, July 28, 2011
Floating Point Numbers
What is a Floating Point Number: There are two ways a decimal/fractional number can be represented in binary form - fixed point and floating point. In a fixed point number, the decimal point is in a fixed arbitrary position which is predefined. For example, in a 32 bit fixed point number, the decimal point may be assumed to be after the 16th bit. So any value represented by the 32 bits needs to be divided by 216 = 65536, to get the value of the decimal number represented by a fixed point.
A floating point number on the other hand has a completely different representation. A floating point number compromises on precision for achieving the following.
A floating point number on the other hand has a completely different representation. A floating point number compromises on precision for achieving the following.
- Broader range of numbers that it can represent
- The precision of the number is fixed, irrespective of its value
- Represent special values like infinity and not-a-number
Saturday, July 23, 2011
Java enterprise framework developers' tools
Wanna develop your own framework? Developing your own framework is sure geeky. Fortunately, in Java, doing so is not as difficult as it seems. But, why develop a framework when there are too many of them already available there? Well, firstly its fun, but more importantly, the existing frameworks might not right away give you all you need. In that case, it might be a good idea to at least extend those frameworks to meet your needs.
Please note that there are so many things you can use and my list is definitely not exhaustive. It just gives idea about a few good ones that come bundled with Java SE.
Please note that there are so many things you can use and my list is definitely not exhaustive. It just gives idea about a few good ones that come bundled with Java SE.
Wednesday, July 20, 2011
Traversing the XPath
What is XPath: XPath is an expression language that points to data represented in an XML document. XPath can point to one or more nodes in an XML document and perform basic arithmetic operations. XPath is a very rich language and selection of nodes can be based on any condition including arithmetic comparisons.
Why is XPath important: XPath is used in many other very important specifications. For example, XML Styling Language Transformation (XSLT), and XPointer (XML Pointer). XML Styling language Transformation can be used to generate one XML from another. It can also be used to generate human readable XHTML documents from an XML document. XPointer itself is used in specifications like XLink. (Which I discussed in earlier posts)
Saturday, July 16, 2011
What's new in Java 7 - Project Coin
What's new in Java 7: Well, its a major version upgrade, there needs to be a lot of things coming up. Of course the most noticeable feature set for a java programmer would be the language level change, i.e. Project Coin. Although the changes are not as major as generics (that came with version 5, which was the time they dropped the "1." from the version number.) or annotations (also came with the same version). But, I guess they are at least as good as auto-boxing.
What is Project Coin: Project Coin or JSR334 is the common JSR that embraces all language level changes that comes in Java 7. I will talk about its features one by one.
What is Project Coin: Project Coin or JSR334 is the common JSR that embraces all language level changes that comes in Java 7. I will talk about its features one by one.
Sunday, July 10, 2011
XPointer Primer
In my earlier post on XLink, I have explained that XLink uses XPointer to point to nodes in the XML. So, I decided to write an article on XPointer.
What is XPointer: XPointer is a specification that allows pointing to nodes in an XML. XLink in dependent on XPointer specification, and so is XPath specification, which is used heavily in XSLT(XML Styling Langage Transformation). XPointer is compact and non-XML, and is designed to be able to fit into a URL (in the fragment part).
What is XPointer: XPointer is a specification that allows pointing to nodes in an XML. XLink in dependent on XPointer specification, and so is XPath specification, which is used heavily in XSLT(XML Styling Langage Transformation). XPointer is compact and non-XML, and is designed to be able to fit into a URL (in the fragment part).
Monday, July 4, 2011
X-Link Extended Links
What is X-Link: X-Link is a specification that allows to link between different XML tags. It is very much like an anchor in HTML, you know the regular <a href="..."></a>. However, X-Link is much more versatile and powerful as we will see.
Unlike HTML anchor tag (which is defined to be able to display a visible link), the use of X-Link is not that limited, and depends on where it is used (Is not all other XML based specifications). As such X-Link specification is not designed to be used on its own, there must be other specifications that define specific rules to use it. It is pretty much like XML itself. XML can be used in many ways, and other standards and specifications define what some XML content means. SOAP and WSDL are two specification that use XML specification. Similarly, Extensible Business Reporting Language is a specification that uses X-Link.
Unlike HTML anchor tag (which is defined to be able to display a visible link), the use of X-Link is not that limited, and depends on where it is used (Is not all other XML based specifications). As such X-Link specification is not designed to be used on its own, there must be other specifications that define specific rules to use it. It is pretty much like XML itself. XML can be used in many ways, and other standards and specifications define what some XML content means. SOAP and WSDL are two specification that use XML specification. Similarly, Extensible Business Reporting Language is a specification that uses X-Link.