Pages

Thursday, May 3, 2012

Handling exceptions in ExtJS

Problem Statement: I struggled almost for a week to fix exception handling in ExtJS. The problem is when I make an AJAX call or make any asynchronous server side call, I was not able to read exact exception message thrown by server. I saw different ways to implement exception listeners in ExtJS but most of them didn't work for me.

Problem Solution: This is what I am using to handle exceptions in ExtJS.

var reportProxy = new Ext.data.HttpProxy({
    url : 'myReportURL',  // web URL
    method : 'post',      // HTTP method
    timeout : 180000,     // request timeout
    listeners : {         // configure listener
        exception : function(proxy, type, action, options,
                response, arg) {
            // this block is reached on any exception
            if (!response.isTimeout) {
                // check if response didn't timed out
                Ext.Msg.show({
                    title : '',
                    msg : "Oops !! There is some Internal Server Error.",
                    buttons : Ext.Msg.OK,
                    icon : Ext.MessageBox.INFO
                });
            } else {
                // this block is called on response timeout
                Ext.Msg.show({
                    title : '',
                    msg : "Its taking too long. Response timed out.",
                    buttons : Ext.Msg.OK,
                    icon : Ext.MessageBox.INFO
                });
            }
        }
    }
});

Note the syntax for defining exception block, the function signature is important. I have seen different signatures for this function but this is the one that worked for me.

Tuesday, May 1, 2012

Features of Java 7


Initially Java 7 was proposed to have many new features such as
  1. Modularization
  2. Anonymous methods (closures)
  3. Simplifications in generics implementations
  4. Enhanced exception handling
  5. Strings in switch statements
  6. Dynamic languages support
  7. Simplified initialization of collections
  8. Elvis operators
  9. API changes
Out of above listed features a few were dropped from actual release of Java 7 and they are supposed to be released as part of Java 8. And they are 
  1. Anonymous methods (closures)
  2. Simplified initialization of collections
  3. Elvis operators

New features in Java 7
  1. Change in language syntax
    • Constants
      • Binary constants
      • Underscore in numeric constants
    • Strings in switch statement
    • Extended try catch
    • Multi-catch
    • Diamond operator
  2. Better support of dynamic languages
    • New bytecode  instruction
    • New dynamic linkage mechanism
  3. JDBC 4.1
    • try-with-resources statement
    • RowSet 1.1
  4. NIO 2
    • Comes with a set of views
    • New abstract class java.nio.file.Path
    • Notion of metadata
  5. Updates in Swing API
  6. Unicode 6
  7. Updates in concurrency package
  8. Automatic resource closure

Monday, April 30, 2012

Object Oriented Analysis & Design

Why object orientation ?
  1. Higher level of abstraction
  2. Seamless transition among different phases of software development
  3. Encouragement of good programming techniques
  4. Promotion of reusability


Unified Approach (UA)
Based on the Booch, Rumbaugh and Jacobson methodologies.
  1. Use case driven development
  2. Utilize the unified modeling language (UML) for modeling
  3. Object-oriented analysis
  4. Object-oriented design
  5. Repositories of reusable classes and maximum reuse
  6. The layered approach
  7. Incremental development and prototyping
  8. Continuous testing 


Objects
  1. The term object was first formally used in the Simula language.
  2. Object have properties or attributes and behaviors.
  3. Objects respond to messages. Messages essentially are nonspecific functional calls. For example, we would send a draw to a chart  when we want the chart to draw itself. A message is different from a subroutine call, since different objects can respond to same message in different ways.
Objects respond to messages according to methods defined in its class. Message is the instruction and method is implementation.


Object relationships
Association: Represents the relationship between objects and classes.
  1. Associations are bidirectional - that means they can be traversed in both directions, perhaps with different connotations.
  2. Cardinality - specifies how many instances of one class may relate to a single instance of an associated class.
Dependency: One class is dependent on other.

Generalization: One class is generalized from other. This is typically known as class inheritance in object oriented programming terms.

Realization: This brings interfaces into consideration.

Sunday, April 29, 2012

Web 3.0

The future of web is going to be lot more powerful then we see today. People already started calling it as Web 3.0. Web 3.0 is all about building the semantic web and the future of web apps is termed as "Semantic Web Applications".

There are two possible aspects to the future of Web. The first is Social networking and people centric web and the second would be Semantic nature of the web. Today's web has got hell lot of information but web by itself do not understand the relationship between the data it has got. The web technology of today focuses more on how web pages are displayed and what content is displayed, rather than on the content itself. So whatever web does today, it does with the help of human intervention, it needs someone to provide ample guidance on what to do. Web is not smart enough to predict something and react to it.

The key features of Web 3.0 will be
  1. Semantic web (meaning of data)
  2. Personalization
  3. Intelligent search
  4. Behavioral advertising
  5. Metadata
More on Web 3.0
http://www.labnol.org/internet/web-3-concepts-explained/8908/
http://computer.howstuffworks.com/web-30.htm
http://en.wikipedia.org/wiki/Web_2.0#Web_3.0