Monday, December 7, 2009

Where will the Web be in 5 years?

Very interesting question. Question that many bloggers, visionaries, techies, CEOs, VCs etc are frequently think of or discuss about.

My humble and honest answer to the question is "I don't know". Though it is true, this may not be an attractive answer for anybody who would expect one. In the web, there are many thoughts, discussing many different dimensions on and of this topic. Not sure any of those will serve as a crisp answer as well. So I was thinking little bit harder and arrived an answer, which is again "I don't know". But this time with some additional thoughts as below.

Though I couldn't predict, its sure, in the next 5 years, the web won't stay where it is now. I can tell this based on the below facts from my personal experience.

15 Years back : Web was just a topic on trend talk / discussions.

10 Years back : Used the Web for my personal use, like Email, Chat and Search. Buzz words of the time were hotmail, yahoo mail, usa.net mail, msn search, yahoo search.

5 Years back : Banking, online bookings, blogs etc are the new big reasons to use web. Web and its young kid 'Google', already started playing a major role in my career. More than personal reasons, job was the reason to use Web. Many web development frameworks came to existence (like struts, spring etc).

Now : Web's nature is growing in the direction of 'Cloud computing'. Many social networks, online collaboration tools, more organized information in web. High volume of web applications and better communication infrastructures give birth to smart phones, which leads the new way of using the web. From time, weather, email, facebook, twitter, youtube, ... to the high end of GPS, smart phones help with the help of web. New generation of web development frameworks (like jQuery, GWT, Java FX, Flex etc) are emerging and contributing more towards productivity, performance and user experience.


As you can clearly see, Web has evolved in many dimensions from its beginning and it is no more static. My reasons to use web also evolved along with web. Not only the web, the web infrastructure has shown a tremendous growth as well. You get hard drive spaces for less size and less price. Web in mobile devices and smart phones, is promising. Having witnessed this tremendous growth, and though Web seems to have matured in many ways, I believe this pace of growth will continue through next 5 years and will give birth to lot more new generation of web applications. And I guess most of the web may be accessed through mobile devices.

Saturday, September 19, 2009

What I like to happen in GWT APIs

In my year and half experience with GWT, one thing that constantly worrying me is the number of deprecated classes and methods. Below are few exmaples that I encountered in my GWT development experience.



Deprecated methods in FocusWidget :

addClickListener, addFocusListener, addKeyboardListener, addMouseListener, addMouseWheelListener, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener

Deprecated methods in FormPanel class :

addFormHandler, removeFormHandler

Deprecated Classes :

ClickListener, FocusListener, KeyboardListener, MouseListener, MouseWheelListener, FormHandler



Some times deprecated method is not just replaced by a new method. But in certain cases, the deprecated method is replaced by two or more methods.


For example, consider the addFormHandler() method of FormPanel. Now it is split into the below two methods.

* addSubmitCompleteHandler
* addSubmitHandler

This obviously paves path to the replacement of removeFormHandler method of FormPanel, by the following two methods.

* removeSubmitCompleteHandler
* removeSubmitHandler



Though there is that backward compatibility, so I don't need to replace the deprecated methods or classes immediately, I still don't want to see the name of the method, struck in the IDE. More over, in some cases, it becomes essential to replace the deprecated methods, because the new methods fix certain javascript issues caused by the deprecated methods. Though I'm still a huge fan and very passionate about GWT, I still wish a more solid persistent methods and classnames.

Tuesday, April 14, 2009

GWT experience

After closely watch-dogging every GWT release, finally started GWT development in work last March. Its been a year of exiting experience with GWT development. At first, after reading whole lot of docs and articles and dreaming the amount of time that could be saved, I couldn't wait to jump start with GWT. So at first, used GWT for small new projects, like Source Generator project I develop for my present client. Initially I started Source Generator with regular Javascript and JQuery framework but once deciding on GWT, I moved the project to GWT. It was a wonderful experience to see no hand-written javascript.

However, all I started to worry about was, bringing GWT to the major on-going project that was heavily using the Struts, Spring, JQuery etc. It almost looked to me as a potential set back for GWT development. Because GWT doesn't use a strict MVC pattern. There is no configuration file to specify the view, action, action-mapping etc. So It didn't seem to me right to go for GWT thinking to reduce javascript development time. It could potentially cost much more time to move away from the traditional MVC design. But whenever I started writing javascript, I couldn't think of the benefits of GWT. So I was seriously looking for a possible way to integrate the on-going Struts / Spring project with GWT. Thank God and thank Sumit Chandel, a support engineer @google, for his post "Developing Web 2.0 Apps with the Google Web Toolkit, Part 2". In that article he explained "Integrating GWT with other web application frameworks" (Struts and Spring). This article came to me at the time and I was amazed by the power of RootPanel and its get() method. Here is the small snippet from the article.

"After having explained this, it’s clear that the Struts MVC implementation and the aforementioned GWT MVC implementation don’t mesh very well, and it would be difficult and nonsensical to find a midway solution so that they would mesh. However, although integrating GWT and Struts infrastructures could prove to be an arduous task, integrating GWT modules into a web application based on the Struts framework is very simple.

This is possible due to the general purpose RootPanel.get("some_id").add() method call. Looking back to our FruitMart web application, we added the mainPanel to the RootPanel by calling RootPanel.get().add(mainPanel) in the entry point class’ onModuleLoad method without passing an argument to RootPanel.get(). This added the mainPanel to the “body” of the page, in essence making the GWT application become the page itself.

When we call RootPanel.get("some_id").add(mainPanel) with “some_id” as a parameter, we’re telling the GWT bootstrap procedure to look for an element with “some_id” in the page, and bind the GWT application to that element. What this means is that by defining an element with “some_id” in some arbitrary web page and including the GWT application bootstrap file, the GWT application will load up as a component on the page in the designated element."


I went with the way as was in the article. But I believe GWT needs some strong MVC patterns and may be a more standardized way is required to integrate existing web frameworks with GWT.

Friday, January 23, 2009

phpBB with MySQL

Recently I was looking to set up a forum. Plenty of them listed here in wikipedia. I went with phpBB.

Atfirst, the Quick Start guide seemed little lengthy. But once started reading, I was able to setup and run the forum in minutes though there was a significant problem I faced while installation. It was setting up the database. I used MySQL with the default storage engine as INNODB. The phpBB installation schema for MySQL created errors if I use the INNODB engine. Tables were not created.

After doing some research, I had to change the storage engine to MYISAM. Then the installation went through and the forum started running good. So if you need to install phpBB with MySQL then you might need to change the storage engine to MYISAM.

If you want the MySQL to use MYISAM all the time, you can set the storage engine in the my.ini file. Command might look like below.

default-storage-engine=MYISAM

Otherwise you can choose to use the MYISAM just for the phpBB installation. And once the installation is over, you can start using the INNODB engine. For this, you can edit the MySQL schema files bundled with phpBB and add the below line as the first line of the schema.

SET storage_engine=MYISAM;

This way the tables will be created without any problem. But I'm not sure if this solves the problem completely. Will post my findings.

Friday, January 9, 2009

Multi database connections

I was using JGrinder as ORM tool for quite some time. Till now, I connected to a single database using JGrinder. And I believed that the JGrinder can connect only one database per JVM. Recently I got a requirement to connect multiple databases in a single JVM. I was not sure it would be possible to do it in JGrinder. So dug it little deeper. Main draw back with JGrinder is that there are not much help documents or forums to talk about it. But after looking at little deeper, I found a way to connect to more than one database in a single JVM using JGrinder. Below is a brief explanation followed by the source code I wrote for it.

JGrinder uses one broker object for each database connection. By default when the following code is executed, a new broker is created with the database details mentioned in the 'fileName' argument.

com.objectwave.appSupport.StartupRoutine.loadDefaults(caller, fileName);

The new broker created will be the default broker by the JGrinder. If more databases need to connected on the fly, broker for each database need to be created and added to the BrokerFactory of JGrinder. When adding the additional brokers, it is necessary to pass a brooker name / tag for the broker, which can be used to identify the broker later to connect to the desired database. The way I used to add additional brokers, is by reading the additional jdbc.ini files. Below is the source code (IniLoader.java) I wrote to load multiple jdbc.ini files. I hope the source code can explain the rest. You can use and distribute this source for free, as long as you abide by the JGrinder licensing terms for its usage.




/*
* ========================================================================
* IniLoader
* ========================================================================
*
*/

package com.pinetree.utils.io;

import com.objectwave.persist.BrokerFactory;
import com.objectwave.persist.broker.RDBBroker;
import com.objectwave.persist.properties.BrokerPropertyDetail;
import com.objectwave.persist.properties.BrokerPropertySource;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.Properties;

/**
* IniLoader is used to load multiple jdbc.ini files into the BrokerFactory of
* JGrinder. Loading multiple jdbc.ini files will allow the developer to use
* any of the database defined in the loaded jdbc.ini files from the same JVM.
*
* Here is the sample usage of loading multiple jdbc.ini files.
*
* IniLoader.addDefaultIni(this, "dev_ecpis_jdbc.ini");
* IniLoader.addIni(this, "epics_jdbc.ini", "epics");
*
* Here is an example of connecting to the default database
*
* try {
* ApplicationContainer ac = new ApplicationContainer();
* ac.setAppNo(1234);
* SQLQuery sqlQuery = new SQLQuery(ac);
* Vector resVec = sqlQuery.find();
* if (resVec != null) {
* ac = resVec.get(0);
* System.out.println("Insured Name : " + ac.getInsuredName());
* }
* } catch (Exception e) {
* e.printStackTrace();
* }
*
* Here is an example of connecting to a database other than the default one.
* All needs to be done is to set the broker name to the tag used to add the
* corresponding jdbc.ini file. For example we added epics_jdbc.ini file with a
* epics tag. So to connect to the epics database, it is necessary to set the
* broker name to "epics", as below, before querying it using the SQLQuery object.
*
* try {
* ApplicationContainer ac = new ApplicationContainer();
* ac.setAppNo(1234);
* ac.setBrokerName("epics");
* SQLQuery sqlQuery = new SQLQuery(ac);
* Vector resVec = sqlQuery.find();
* if (resVec != null) {
* ac = resVec.get(0);
* System.out.println("Insured Name : " + ac.getInsuredName());
* }
* } catch (Exception e) {
* e.printStackTrace();
* }
*
*
* @author jerald
*/

public final class IniLoader {

/**
* loads an jdbc.ini file. Any read or write done on the container without
* setting the broker name will use this jdbc.ini file details to connect
* to the database.
*
* @param caller reference of the object that called this method
* @param fileName name of the jdbc.ini file
*
*/

public static void addDefaultIni(Object caller, String fileName) {
com.objectwave.appSupport.StartupRoutine.loadDefaults(caller, fileName);
BrokerFactory.useDatabase();
}

/**
* loads an jdbc.ini file specified in the arguement with the tag name as
* passed in the argument. When the broker name of a container is set to
* the tag passed in this argument, any read or write done on the container
* will happen on the database defined in the jdbc.ini file as passed in the
* argument.
*
* @param caller reference of the object that called this method
* @param fileName name of the jdbc.ini file
* @param tag tag that to be associated with the jdbc.ini file
*/

public static void addIni(Object caller, String fileName, String tag) {

final String URL_TOKEN = "ow.connectUrl";
final String USERNAME_TOKEN = "ow.persistUser";
final String PASSWORD_TOKEN = "ow.persistPassword";
final String DRIVERNAME_TOKEN = "ow.persistDriver";
final String DBIMPL_TOKEN = "ow.databaseImpl";

if (tag == null) tag = fileName;

InputStream inputStream = null;
Properties props = null;
try {
inputStream = ClassLoader.getSystemResourceAsStream(fileName);
} catch (Exception e) {}

if (inputStream == null) {
if (caller instanceof Class) {
inputStream = ((Class) caller).getResourceAsStream(fileName);
} else {
inputStream = caller.getClass().getResourceAsStream(fileName);
}
}

try {
if (inputStream != null) {
BufferedInputStream bis = new BufferedInputStream(inputStream);
props = new Properties();
props.load(bis);
}
} catch (Exception e) {
e.printStackTrace();
}

if (props != null) {
String connectUrl = props.getProperty(URL_TOKEN);
String userName = props.getProperty(USERNAME_TOKEN);
String password = props.getProperty(PASSWORD_TOKEN);
String driverName = props.getProperty(DRIVERNAME_TOKEN);
String dbImpl = props.getProperty(DBIMPL_TOKEN);

if (connectUrl != null && userName != null &&
password != null && driverName != null && dbImpl != null) {
try {
RDBBroker broker = new RDBBroker();
BrokerPropertyDetail bpd = new BrokerPropertyDetail();

bpd.setConnectUrl(connectUrl);
bpd.setPersistUser(userName);
bpd.setPersistPassword(password);
bpd.setPersistDriver(driverName);
bpd.setDatabaseImpl(dbImpl);
BrokerPropertySource bps = new BrokerPropertySource(bpd);
broker.setBrokerPropertySource(bps);
broker.initialize();
BrokerFactory.addStaticBroker(tag, broker);
} catch (Exception e) {
e.printStackTrace();
}
}
}

}

}


Sunday, April 6, 2008

Net Beans 6.1 Beta

After trying so many IDES starting from AdventNet Bean Builder, Emacs, GVIM, Eclipse & Netbeans, I now find the Net Beans more convenient for my development. Recently I downloaded the NetBeans 6.1 Beta. One thing I like most, is the improved Java Script support. Code completion is more relevant now in 6.1 Beta than in 6.0.1. One other thing I liked is the comment section. Previously when I type enter after opening a comment section with a forward slash followed by two stars (/**) a new line with a star followed by a space (* ) will be added by default. It will look like below.




Cursor will be at the position of the hypen in the above line. If I need to close that comment section, I need to type a backspace and a backslash.

Now in 6.1 Beta if I open a comment section and type enter, the comment section will be completed by default, with some intelligence.

1) If a comment section is opened for anything other than class definition or method definition (one exception to this is a method definition with no arguments and which returns void), it is completed as below and the cursor stays at the position of the hypen.




2) If a comment is opened for class definition, it is completed as below.




If a comment is opened for method definition, it is completed with little more smartness.

3) For a method which takes no arguments and returns an object, comment section is closed as





4) For a method that takes some arguments and returns anything but void, comment section is closed as below.




It is something that is not much to do with any functionalities but is a cool function that caught my interest.

Apart from these, one thing I haven't figured out yet is the collapse and expand code. It is not working as it was in 6.0.1. When you start editing the code, suddenly, the collapse / expand is not functioning. When I close the IDE and start again collapse / expand is back. I guess there is something to be fixed. Let me hope for the fix soon.

Tuesday, October 16, 2007

Not the knowledge but the Passion

8 years back, I used to wonder at the new software products on the market. That was the time Google was trying their hand on the search, and was the time I was looking out for a job as a fresher. I always used to wonder at the hot new software products and the brains behind that. I really thought one should posses really really a super brain to write applications of that kind, I saw then. I developed a small game in 'C using graphics and sound libraries. It was exiting. And I know how complex it is to animate your objects on the screen.

Soon after I joined my first job, I was in the development of an application thats a kind of a mash of GIS (Geographical Information System) and MIS (Management Information System) using Visual Basic, ESRI Map Objects and MS Access. That was out of the concept of my manager who was doing his Phd in Geology then and truly was interesting for me. I felt how great it is to grow stronger and stronger on technical. After that product, I was writing some automation scripts for some applications.

Then moved to a java based firm which I hardly knew about it before joining. I was astonished to see the energy and enthusiasm I found in there. After spending some good time there I had to give up my perceptions. I just not realized but witnessed that it is no the sound technical knowledge that takes you to deliver the world class products. But it is the passion.

And recently, I happened to look at a framework of a software application. Looking at the code, the application seemed to be so complex. But after spending some good time on the code, i'm sure the framework could be more simpler. May be there is a time crunch or other pressures and more for the quality of the development. But beyond that you need to have some passion to write code. This passion can deliver more than your technical skills. I have personally seen some freshers with not much experience deliver more than the experienced people. And i believe it is only out of the passion.