Tuesday, November 17, 2015

Java Exception Propagation and Handling


Today I had to design some interfaces for an infrastructure component that we are developing and one of the questions in my mind was about what would be the correct exception handling mechanisms for the implementations of this interface.  I found a very nice and informative article here by Brian Goetz an authoritative expert source on Java   :

Java theory and practice: The exceptions debate

For those who have worked for some time with Java,  the terms checked exceptions  and unchecked exceptions would immediately spring to your mind.  To state in a brief one-liner :

Checked Exceptions derive from java.lang.Exception whereas Unchecked Exceptions derive from java.lang. RuntimeException.

An interface declaration has to explicitly declare the type of checked exceptions that could be thrown from it's methods. This means that the client invoking these methods should handle them explicitly using the try-catch-finally technique or must re-throw  them so that they are handled up the call stack. For example, many methods within the JDBC SPI throw SQLException. This mandates callers using the SPI to handle this exception or re-throw it.

 Unchecked exceptions on the other hand need not be explicitly declared within the interface definition. For example if the implementation of an interface does not support a method then it throws an UnsupportedOperationException which is a RuntimeException. For an even more concrete example  see the implementation of the Collections.unmodiableList. More specifically see how java.util.Collections.UnmodifiableList has been implemented.

So in order to design interfaces correctly - please re-read exception handling, think through the functionality and yes definitely read the link posted above.

Happy Coding!!

Saturday, June 6, 2015

Validating CSS Properties


I came across an interesting post on StackOverflow related to CSS Validation. Here is a link to the question of interest:

Checking for Valid CSS properties

The answer to this question highlights the extremely simplistic manner in which we can validate styles for a web page.

Another common error that happens in the course of web development is the using  invalid CSS class names while styling an element. It would be great if there was a way to validate before we send the page into production that all our CSS styles are indeed valid.

This can be done using the below algorithm:
  1. Enumerate all the applied CSS classes for a web page. This can be done as a per a SO query here
  2. Identify the CSS file resource to which this style belongs.
  3. If step 2 cannot be completed successfully for any class, then we are dealing with an invalid CSS class.

 Hopefully,  this helps someone(including myself when I come back looking around after some time on how this needs to be done ;))



Saturday, April 6, 2013

Resolve the ATBroker Crash issue on RDP logon to Windows

Here is a link that describes how to resolve a strange Atbroker.exe crash at RDP logon to Windows
Atbroker crash workaround

Saturday, November 13, 2010

IKVM.NET a JVM CLR bridge

While reading through the Mono web pages, I came across an interesting project known as IKVM.NET.
This project strives to bridge the gap between the Java and the .NET world, by providing a JVM written over the .NET framework. What this essentially means is that now there is a way to easily convert a Java library into a .NET library and vice versa.


It is also possible to develop a .NET application in Java and a Java application in .NET.


Many may question the rationale behind such a framework. Earlier even I too was skeptical about this framework. But as I am involved with some projects, I realize that this framework strives to solve a dilemma that many developers faced earlier - how to use the facilities of a mature framework available on platform into the other. 


For example; today there does not seem to be a platform independent way to read MS Word documents in .NET. You have to necessarily use COM interfaces exposed in the Microsoft Office PIA. This will work fine on Windows, but with the advent of Mono, .NET apps are no longer restricted to Windows platforms.. So now I wanted to port this code to Mono on my Mac OS but could not do so as this code uses COM which is Microsoft specific technology.


I found that I could use the Apache POI to read word documents in Java in a platform independent manner and that the POI framework is pretty mature. Now using IKVM I can convert this POI library into a .NET dll and consume the classes.


I am working on this now and will blog about my experiences in another post.



Monday, November 1, 2010

Sequence Diagrams on Demand

I was looking out for a tool that would help me to draw Sequence diagrams with ease. And then I came across this interesting site called as WebSequenceDiagrams.

When the home page for the site loads, you do not see anything fancy except a sample sequence diagram and some text panel at the left. But then this is where the magic all begins!!

Actually the text on the left pane directly maps to the sequence diagram being drawn on the right and then there are a set of sequence diagram templates to be chosen from too from a pallete.

So to modify the sequence diagram, you modify the text by following a particular syntax, the sequence diagram auto updates itself as you specify in text the various interactions between the participating entities on the left.

Visit the site and post comments!!




Friday, September 24, 2010

FSSearchIndex Framework - An open source document indexing and search framework

Hello All,

Through this post I wanted to share with the world something that I have been working on for the past year. I am currently working on a cross platform, low cost desktop content search framework.

I was struck with the idea of developing this framework, when during the course of some assignment I figured out that there is no easy way to search for a file based on it's content,even though such an activity is one of the most common one on any desktop system.
We today do not have cross platform content search and indexing frameworks; most of the content search and indexing frameworks like Windows search make use of platform specific proprietary technologies. Others like Google search while being cross platform provide for integration using platform specific technologies like COM. Worse GDS can only be interacted with using Javascript on non-Windows OS.
The FSSearchIndex framework API has been developed to be simple and easy to use - with just 5 lines of code you can actually build your own indexing or searching application.
This project is open-source and free of cost for usage. It has been hosted on SourceForge.NET and Codeplex.

Request you all to try them and let me know how this can be improved. Any contributions towards this in terms of design, code, testing and documentation are welcome.
Since currently I am developing these single handedly there may be bugs in the Beta code base hosted at the below site.These will be ironed out over time.

Thank you once again and hope you give this framework a try.