- Inheriting the implementation
- Inheriting the declarations
This platforms is to share technology findings and knowledge that help others in every possible way. Contributors of the blog believe that they learn from something and continuous learning is key to spread knowledge across.
Sunday, 27 March 2011
Multiple Inheritances in java and the controversy
Thursday, 17 March 2011
HTML5 Web Storage API
- Storage limit: Cookies can store 4KB data only
- Performance issues: With every request cookies are transmitted to server
- Accessibility issues: Per domain there are numbers of cookies created by different browsers
Tuesday, 15 March 2011
Java design Techniques – Using Interfaces Part – 2
- It's easier to change classes involved in a composition relationship than it is to change classes involved in an inheritance relationship.
- Composition allows you to delay the creation of back-end objects unless they're needed. It also allows you to change the back-end objects dynamically throughout the lifetime of the front-end object. However with inheritance this is not true, you get the image of the super class in your subclass object image as soon as the subclass is created, and it remains part of the subclass object throughout the lifetime of the subclass.
- It's easier to add new subclasses (inheritance) than it is to add new front-end classes (composition), because inheritance comes with polymorphism. If you have a bit of code that relies only on a super class interface, that code can work with a new subclass without change. This isn't true for composition, unless you use composition with interfaces.
Monday, 14 March 2011
HTML5 Web notification API
Introduction
Web notifications are the ability for an application to notify user even if they are not at the web page in the form of small notification popup box. This creates a great deal for the web applications where even if the interaction between the web application and user is not in synch they can have notifications reached to the end user.
Let me first introduce you to the various types of the notifications so it will be easy to explain different use cases for.
- Ambient notification: A notification which appears and disappears automatically without user action.
- Interactive notification: A notification which can receive events from user actions and deliver them to the application which created the notification.
- Persistent notification: A notification which is displayed until the user explicitly dismisses it.
- Notification platform: A notification platform is a system outside the browser which provides desktop notifications. Examples include Growl on MacOS, NotifyOSD on Linux, and the Windows notification API.
- Simple notification: A notification which consists only of an icon and one or two lines of text.
- Web notification: A notification which consists of Web platform content, such as HTML or SVG.
This specification provides an API to generate simple notifications to alert users outside of the web page. When this specification refers to displaying notifications on the "desktop", it generally refers to some static display area outside the web page, but may take several forms, including:
- a corner of the user's display,
- an area within the chrome of the browser,
- the "home" screen of a mobile device
User case
When an application need to display email related notifications to user about ‘new email arrived’ it can display ambient notification with new email subject, from, etc. fields or it can display an interactive notification with an ability to return to inbox.
An application where it needs to display a upcoming meeting notification that the user might have set in his calendar or interactive notification that will allow user to snooze the meeting reminder for specific time interval.
Sometimes it can also span over wide range of notifications where say some one has posted on user’s comment, status on Facebook and user has opened multiple tabs in browser where Facebook needs to notify user about this activity.
Some application like Flicker or Picasa might want to notify user about his image upload completion progress by the time he has navigated away from the current tab.
One of the security aspects that need to be considered by an author is to make sure that the user has granted permission for a notification to appear on his platform.
Examples
Notification objects dispatch events during their lifecycle, which authors can use to generate desired behaviors. The show event occurs when the notification is shown to the user -- this may be at some time after the show() method is called in the case of limited display space and a queue. In the following example, this event is used to guarantee that regardless of when the notification is shown, it is displayed for only 15 seconds.
var notification = new Notification("mail.png", "New Email Received");
notification.onshow = function() { setTimeout(notification.cancel(), 15000); }
notification.show();
When a meeting reminder notification is acknowledged, the application suppresses other forms of reminders.
var notification = new Notification("calendar.png", "Meeting about to begin", "Room 101");
notification.onclose = function() { cancelReminders(event); }
notification.show();
Saturday, 12 March 2011
HTML5 Server-Sent API
Introduction
This specification defines an API for opening an HTTP connection for receiving push notifications from a server in the form of DOM events. The API is designed such that it can be extended to work with other push notification schemes such as Push SMS. It can also be used to implement connectionless Push notification as described in below use case.
When we would like to push data to web pages over HTTP or using some dedicate server-push protocol this API can be used. It offers the use of EventSource interface to implement this functionality. Using this API we will need to create an EventSource object and registering an event listener to show various readyState as CONNECTING (numeric value 0), OPEN (numeric value 1) and CLOSED (numeric value 2).
While the connection is alive with the server the user agent will be required to parse and interpret the event stream of MIME type text/event-stream
Use case
In case of Stock application when we would like to minimize the load on client especially if it is on the portable device like mobile to save battery power and reduce network load the push notifications can certainly help. This will require server side implementation to support pushing of data to client. This can be a good alternative rather than using XMLHttpRequest or an iframe.
The browsers on mobile handsets tied to specific carriers, may offload the management of the connection to a proxy on the network. In such a situation, the user agent will be implementing the connectionless push notification with the help of some ‘push proxy’.
For example, a browser on a mobile device, after having established a connection, might detect that it is on a supporting network and request that a proxy server on the network take over the management of the connection. In between two messages, the browser detects that it is idle except for the network activity involved in keeping the TCP connection alive, and decides to switch to sleep mode to save power. Here the browser will disconnect from the server and the "push proxy" service will contact the remote HTTP server and requests the resource and if available then it will convey the event to the mobile device, which wakes only enough to process the event and then returns to sleep.
This can reduce the total data usage, and can therefore result in considerable power savings.
The only challenge is if user is opening multiple pages from the same server that is using this API. In such cases isolated domain per page might be required to solve the problem or implementing push objects with the help of Webworker API.
Examples
The user agent will create the EventSource object as described below and have a listener for incoming data.
var source = new EventSource('stockupdates.cgi');
source.onmessage = function (event) {
alert(event.data);
};
On the server-side, the script ("stockupdates.cgi" in this case) will send messages in the following form, with the text/event-stream MIME type:
data: This is the X stock value for AAA stock option.
data: This is Y stock value for BBB stock option
data: with deviation from previous value as 4.
Friday, 11 March 2011
HTML5 Webworker API
Introduction
This specification defines an API for running scripts in the background independently of any user interface scripts. This allows for long-running scripts that are not interrupted by scripts that respond to clicks or other user interactions, and allows long tasks to be executed without yielding to keep the page responsive.
Workers (as these background scripts are called herein) are relatively heavy-weight, and are not intended to be used in large numbers. For example, it would be inappropriate to launch one worker for each pixel of a four megapixel image.
Generally, workers are expected to be long-lived, have a high start-up performance cost, and a high per-instance memory cost.
User case
As the web worker API allows us to implement multi threading behavior to a web application imagine a Stock application requires doing multiple things at the same time, getting stock updates on timed interval and finding quotes for specific stock option based on user search criteria. This can be a very good example to think about web workers to be used.
Another use case could be where the application is required to display different views for the map say regular map view, satellite view, hybrid view and 3D map view displaying same region at the same time. User can switch between maps to move map directions in any of the views where all the maps should get updated to show the respective region in their view.
Examples
HTML5 JS API specification and use cases
- the possibility to attach files to messages,
- A callback on success / error when a message is sent
This specification defines an interface for web applications to access timing information related to navigation and elements.
For more information http://geeksinaction.blogspot.com/2011/06/navigation-timing-api.html
Wednesday, 9 March 2011
Java Design Techniques – Using Interfaces Part - 1
abstract class Animal {
abstract void talk();
}
class Dog extends Animal {
void talk() {
System.out.println("Woof!");
}
}
class Cat extends Animal {
void talk() {
System.out.println("Meow.");
}
}
class Interrogator {
static void makeItTalk(Animal subject) {
subject.talk();
}
}
void talk();
abstract class Animal implements Talkative {
abstract public void talk();
class Dog extends Animal {
public void talk() {
class Cat extends Animal {
public void talk() {
class Interrogator {
static void makeItTalk(Talkative subject) {
class CuckooClock implements Talkative {
public void talk() {
public static void main(String[] args) {
Tuesday, 8 March 2011
New age Mobile application development using MVC
MVC is especially appropriate for Mobile applications. It can typically have a substantially larger number of specifically purposed user interface modules. So the more rigorous attention to mobile development that is implied by good MVC design makes keeping the design more tightly focused on single-purpose units that are consistent in their abstractions and play well together. At the same time, this pattern helps partition functionality into modules that can more cleanly defined with solid coherence while being more precise about limited cohesion where it properly belongs.
There are few mobile application development frameworks based on MVC pattern available in market. Sencha Touch is a powerful way to build mobile apps, and, because it relies entirely on web technologies, we can easily host those apps on the web server and have users find and access them directly from their mobile browsers. Another one is the M-project that contains all UI and Core files to build jQuery Mobile based mobile HTML5 Apps.
To write mobile application we can think of either of the below cited options to achieve a business need.
- Purely native application using mobile specific development platform and libraries.
- Web based application to address the mobile version of web. In this case HTML5 can play vital role to provide greater capabilities like storage methods, offline cache, etc.
- Hybrid application – developed using Webkit control of mobile platform to render the view using HTML and platform specific APIs to implement the business logic.
Model
The model can be a collection of Java script objects or platform specific classes that form a software application intended to store, and optionally separate, data. A front end object that can communicate with any user interface (for example: a mobile specific custom control that represents graphical user interface or a web component like HTML).
View
The view can represented either by the HTML/HTML5 components or platform tailored UI controls, with ability to view data being transported to the page in various ways.
Controller
The Controller communicates with the front end of the model and loads view with appropriate data.