Browsed by
Author: Bibek

Responsive Web Design (RWD)

Responsive Web Design (RWD)

From Wiki
Responsive web design (RWD) is a web design approach aimed at crafting sites to provide an optimal viewing experience—easy reading and navigation with a minimum of re-sizing, panning, and scrolling—across a wide range of devices (from mobile phones to desktop computer monitors).

In simple words we want to develop website that suites all devices. You might have seen few domains have their mobile site different from main site like In such cases you will have to maintain both of the them (more maintenance means more cost). If you have one site that behaves well for all devices (desktop,ipad,iphone etc…) . dont you think that will be great ??? This is what Responsive Design is?

Lets start with an example.

1) Responsive Design
You can just re-size your browser window (to mobile size) to see how it works for the current site (i.e. Or you can check the same in with Mobil devices.
You will notice that the menus are converted to drop downs and study other segments behaviors.

2) Non-Responsive Design
Open this url ( in resized browser window or in Mobil devices. You will see the difference.

As of now you might have understood the significance of responsive design. So lets start working with RWD.

No doubt RWD a big thing now. To newbies, responsive design might sound a bit complicated, but it is actually simpler than you think. Lets learn about the basic logic of responsive design and media queries.

Media Queries : CSS2 allows you to specify style-sheet for specific media type such as screen or print. Now CSS3 makes it even more efficient by adding media queries. You can add expressions to media type to check for certain conditions and apply different style-sheets. For example, you can have one style-sheet for large displays and a different style-sheet specifically for mobile devices.

Example :
The following CSS will apply if the viewing area is smaller or equal to 320px.

You can google to understand more into media quires.

Stay tuned for updates on this article.

JAVA 7 Features

JAVA 7 Features

Key Features

  • Strings in switch Statement
  • Multiple Exception Handling
  • Try with Resources
  • Java nio Package
  • Binary Literals, underscore in literals
  • Diamond Syntax
  • Many others refer to Oracle Release note

JAVA 7 : Code named Dolphin and released on July 28, 2011.

Release Note
Oracle Release Note
Feature Page

Support of String in Switch Case.

String in Switch support are useful for processing data without conversion to enum or if-else logic. Sometimes is just easier to switch on String.

The switch statement when used with a String uses the equals() method to compare the given expression to each value in the case statement and is therefore case-sensitive and will throw a NullPointerException if the expression is null

Binary Literals
Binary literals are new features in Java 7. As you all know that we can write integral types (byte, short, int, and long) in Binary and Hexadecimal formats but from Java 7 onwards we can write these numbers in binary format also. The number should be prefixed with 0b or 0B to be treated as binary literal.

This feature is very helpful to bit-oriented systems like processors, network protocols and bitmapped hardware device. Early the programmer used to transform from binary to decimal/hexadecimal and vice versa. Using this feature will remove this transformation and chances of error will be less in this conversion.
ex :

Underscore Between Literals
In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example, to separate groups of digits in numeric literals, which can improve the readability of your code.

For instance, if your code contains numbers with many digits, you can use an underscore character to separate digits in groups of three, similar to how you would use a punctuation mark like a comma, or a space, as a separator.

Diamond Syntax/Operator
The diamond operator is a nice feature as you don’t have to repeat yourself. It makes sense to define the type once when you declare the type but just doesn’t make sense to define it again on the right side.

The Diamond Operator reduces some of Java’s verbosity surrounding generics by having the compiler infer parameter types for constructors of generic classes.

Catching Multiple Exception Types
In Java SE 7 and later, a single catch block can handle more than one type of exception. This feature can reduce code duplication and lessen the temptation to catch an overly broad exception.
Consider the following example, which contains duplicate code in each of the catch blocks:

In releases prior to Java SE 7, it is difficult to create a common method to eliminate the duplicated code because the variable ex has different types.

The following example, which is valid in Java SE 7 and later, eliminates the duplicated code:

The catch clause specifies the types of exceptions that the block can handle, and each exception type is separated with a vertical bar (|).

Note: If a catch block handles more than one exception type, then the catch parameter is implicitly final. In this example, the catch parameter ex is final and therefore you cannot assign any values to it within the catch block.

Bytecode generated by compiling a catch block that handles multiple exception types will be smaller (and thus superior) than compiling many catch blocks that handle only one exception type each. A catch block that handles multiple exception types creates no duplication in the bytecode generated by the compiler; the bytecode has no replication of exception handlers.

Rethrowing Exceptions with Improved Type Checking
The Java SE 7 compiler performs more precise analysis of rethrown exceptions than earlier releases of Java SE. This enables you to specify more specific exception types in the throws clause of a method declaration.

Consider the following example:

This examples’s try block could throw either FirstException or SecondException. Suppose you want to specify these exception types in the throws clause of the rethrowException method declaration. In releases prior to Java SE 7, you cannot do so. Because the exception parameter of the catch clause, e, is type Exception, and the catch block rethrows the exception parameter e, you can only specify the exception type Exception in the throws clause of the rethrowException method declaration.

However, in Java SE 7, you can specify the exception types FirstException and SecondException in the throws clause in the rethrowException method declaration. The Java SE 7 compiler can determine that the exception thrown by the statement throw e must have come from the try block, and the only exceptions thrown by the try block can be FirstException and SecondException. Even though the exception parameter of the catch clause, e, is type Exception, the compiler can determine that it is an instance of either FirstException or SecondException:

Try with Resources
The try-with-resources statement is a try statement that declares one or more resources. A resource is as an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implements java.lang.AutoCloseable, which includes all objects which implement, can be used as a resource.

Native Keyword / Calling C Program From Java

Native Keyword / Calling C Program From Java

You might have seen in Java API many methods are using native keyword. Lets understand them.

The native keyword is applied to a method to indicate that the method is implemented in native code using JNI.

Definition From JSR
A method that is native is implemented in platform-dependent code, typically written in another programming language such as C, C++, FORTRAN,or assembly language. The body of a native method is given as a semicolon only, indicating that the implementation is omitted, instead of a block.

Still looking more .. google it 🙂

Lets start with an example :

see this link

Stay Tuned… will post an example soon.

JavaScript Utility

JavaScript Utility

Below are few Java Script methods to help you.

Debugging in JavaScript:
Debugging in JavaScript is now become easier with modern browsers.But still you will be facing issues in many cases so the alternative can be writing print statments in javaScript (i.e. console.log(“Message”)).

But in IE browser if you console is not opened (it can be opened with Developer tools (F12)) then it will show function undefined error and will stop further javascript execution. To prevent this you can use console as below.

window.console && console.log (“Message To Log”);

Getting Param From URL
function getParam(name) {
name = name.replace(/[\[]/, “\\\[“).replace(/[\]]/, “\\\]”);
var regexS = “[\\?&]” + name + “=([^&#]*)”;
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null)
return “”;
return results[1];

Example :

You must either modify your dreams or magnify your skills …

getParam(“load”) will return true;

Reload the Page Native Method

Lot more come.. Stay tuned…

Twitter Bootstrap

Twitter Bootstrap

From Wiki
Bootstrap is a free collection of tools for creating websites and web applications. It contains HTML and CSS-based design templates for typography, forms, buttons, navigation and other interface components, as well as optional JavaScript extensions.
It is the most popular project on GitHub and has been used by NASA and MSNBC among others.

Bootstrap was developed by Mark Otto and Jacob Thornton at Twitter as a framework to encourage consistency across internal tools. Before Bootstrap, various libraries were used for interface development, which led to inconsistencies and a high maintenance burden.

Bootstrap website

Bootstrap is simple to use. Look at few examples .

Bootstrap come with many ready to use features. See why to use at this link.