Reality is a perception. Perceptions are not always based on facts, and are strongly influenced by illusions. Inquisitiveness is hence indispensable

Sunday, February 17, 2008

RCP Ideas

Enterprise applications are typically not meant for every one. The users targeted are specialized and knowledgable. The application providers can exploit this aspect and deliver optimized systems for this section of users. Rich UI and client side processing are the exploitable aspects. The problem of connecting client systems to servers is still open. Writing custom socket code or coming up with custom user agents are some solutions. If re-inventing the wheel is not your cup of tea, then the following is for you.

The idea is to use Http unit to communicate with web-apps. Httpunit is developed with the intention of testing webapps on the lines of junit. The interface functionality is tested here. A brief overview of Http unit before we dwell into the facts.
1. The core of http unit is WebConversation, This is equivalent to the application browser window.
2. The requests sent are WebRequests, these carry parameters with them. In webapps, Form submission is one example of request submission.
3. The responses are sent by WebServer, these are WebResponses

WebConversation defines a context within which WebRequests and WebResponses are exchanged. These form a conversational state.

Enough with httpunit, we will look at the possible strategies for RCP UI.

Well designed webapps are typically layered. Presentation layer is the one which feeds the UI. We can retain a simple html based pres layer, without any client validations and build an RCP presentation model on it.

Or, We can do away with the Presentation layer and straight away handle web conversations from the RCP code.

I personally prefer a html layer, It ensures a proper seperation of concerns. Note that this UI need not adhere to the W3C standards. It need not even look visually appealing, (read no complex CSS). No need to bother about client side validations either. (With the advent ot scripting to desktop apps from jdk6, we are seeing new evolutions. We now have new areas like Ajax, flash to add all the gloss).

This being said the problems of managing versions and providing updates to application clients forces new processes to be setup. One of the major benifits that a system provider would get are related to resource usage. If we design for application models on client end, we can save memory and processig speed on server side. Light weight sessions and complex algorithemic computations can be delegate to client. The server would be a data provider and a access provider.

How popular RCP is going to be, only time can tell

Saturday, December 22, 2007

Xbox 360

I bought a xbox 360, never thought that it should be blogged :) I am doing it anyway. The seventh generation of consoles are absolute number crunchers. If any one has worked on a graphics program like adobe photoshop or gimp, they would understand it. Most computers of yester years were good at things like browsing, drafting documents and playing media files. The graphic programers always went for a extra special offering called apple. Any good rendering involves operations that are cpu hungry and memory hungry. Now a days the chasm is being bridged but the divide still exists.

Coming back, the xbox sits like a cute little puppy in the drawing room just beneath the TV. It at time looks melancholic as well. All this changes in a spur of a moment, just switch on the power and insert your favourite game (mine being Gears of war). There is no thunder or lightning, apart from the noise made by the cooling unit. The graphics and visual effects at times dazzle me. I often wonder whose idea was the rocking controller. I have a strong feeling that the 3.2 Ghz 6 core machine will stay with me for a long time.

Jibx with Netbeans

There are times when we face the need to marshall and unmarshall java objects. What better than XML for this! Most programmers can write their own XML parsers and unparsers, why do that when we have a beautiful utility tool. Infact there are several tools. Jibx is one of them, it is offers better performance than many other rivals by using the pull-event mechansim, to top that it is free for use and opensourced. Jibx essentially asks the users to provide a mapping between java objects and xml data. This mapping is provided by users in form of xml file. Lets call it binding xml. Then the users are asked to compile the the project and compile the bindings. The byte code is modified (another reason for the high performance) during this process.

A sample code snippet:
##############################

package ajibx_learning;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ResourceBundle;

import org.jibx.runtime.BindingDirectory;
import org.jibx.runtime.IBindingFactory;
import org.jibx.runtime.IMarshallingContext;
import org.jibx.runtime.IUnmarshallingContext;
import org.jibx.runtime.JiBXException;


public class Main {
/**
* Unmarshal the sample document from a file, then marshal it back out to
* another file.
*/
public static void main(String[] args) {
String ajibxProperties = "ajibx_learning.bizProperties";
String fileInput = "fileOutput";
String fileOutput = "fileInput";
String className = "className";
File fOut = null;
File fIn = null;
Object bean = null;
try {

ResourceBundle rbundle = ResourceBundle.getBundle(ajibxProperties);

fOut = new File(rbundle.getString(fileInput));
fIn = new File(rbundle.getString(fileOutput));
Class c = Class.forName(rbundle.getString(className));
bean = c.newInstance();
} catch (Exception ex) {
ex.printStackTrace();
System.out.print("Exiting ...");
return;
}
System.out.print("Unmarshalling ...");
// unmarshal customer information from file
bean = unMarshall(fIn, bean);
// you can add code here to alter the unmarshalled customer
System.out.print("marshalling ...");
// marshal object back out to file (with nice indentation, as UTF-8)
marshall(bean, fOut);
}

public static Object unMarshall( File fileIn, Object bean){
boolean status = true;
try {
// note that you can use multiple bindings with the same class, in
// which case you need to use the getFactory() call that takes the
// binding name as the first parameter
Class beanClass = bean.getClass();
IBindingFactory bfact = BindingDirectory.getFactory(beanClass);
// unmarshal customer information from file
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
if(!fileIn.exists()) {
System.out.println("File doesnt' exist: "+fileIn.getAbsoluteFile());
return status=false;
}
FileInputStream in = new FileInputStream(fileIn);
bean = uctx.unmarshalDocument(in, null);
in.close();
} catch(Exception e){
status = false;
e.printStackTrace();
} finally {
if(status)
return bean;
else
return null;
}

}

public static boolean marshall( Object bean, File fileOut){
boolean status = true;
try {
// note that you can use multiple bindings with the same class, in
// which case you need to use the getFactory() call that takes the
// binding name as the first parameter
Class beanClass = bean.getClass();
IBindingFactory bfact = BindingDirectory.getFactory(beanClass);
// marshal object back out to file (with nice indentation, as UTF-8)
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(2);
if(fileOut.exists()){
fileOut.delete();
}
if(fileOut.createNewFile()) {
System.out.println("Creating file: "+fileOut.getAbsoluteFile());
}
else {
System.out.println("Failed to create file: "+fileOut.getAbsoluteFile());
return status=false;
}
FileOutputStream out = new FileOutputStream(fileOut);
mctx.marshalDocument(bean, "UTF-8", null, out);
out.flush();
out.close();
} catch(Exception e) {
status = false;
e.printStackTrace();
} finally {
return status;
}
}
}
###############################

I decided to use the following properties file
#bizProperties.properties
# the input file is the source of xml data
fileInput = D:\\temp\\jibx-gen\\Example1.xml
# the outfile is written by the program
fileOutput = D:\\temp\\jibx-gen\\Gen-Example1_2.xml
# the bean which I intended to use
className = beandef.Person
###############################

I then decided to use the good old 'ant' script to compile this. The issue with ant scripts was that, the code cannt be debugged straight away in IDE. So, I decided to have look at the IDE generated ant script. This itself deserved another posting!!. The expressive power of ant is better illustrated in such examples. The modifications done to build.xml are given below. Note that I was using Netbeans5.5.1
##############################

blah blah of netbeans...
Please replace < with <

<!-- modified for the sake of Jibx bindings -->
<property file="nbproject/buildExample1.properties"/>
<!-- JiBX binding compiler task definition -->

<taskdef name="bind" classname="org.jibx.binding.ant.CompileTask" classpath="${file.reference.jibx-bind.jar}"></taskdef>
<!--
-->
<target name="-post-compile">
<echo message= "${file.reference.jibx-bind.jar}" >
</echo>

<!-- Run JiBX binding compiler -->
<bind verbose="true" load="true" >
<classpath path="${run.classpath}"></classpath>
<bindingfileset dir="${binding.dir}" includes="${binding.filenamepattern}" >
</bindingfileset>
</bind>

</target>
</project>
</quote>
###################################

The modifications are done to the "-post-compile" target. The prefix "-" indicates that this target cannot be called directly. This also uses a "buildExample1.properties" file. The binding information is given this file. The bindings are compiled using this information. In case you are perplexed, the actual information for build is given in build-impl.xml. The build.xml is just a wrapper. Some of the tasks are exposed to the user for allowing customisation and in this case "-post-compile" was choosen.
The contents of buildExample1.properties:
##################################
# The directory containing binding files
binding.dir= D:\\temp\\jibx-gen
# for nested files use **/*binding*.xml, for this example we dont' need it
binding.filenamepattern = *binding*.xml
###################################
The complete code for bean and xml used are also given
##############################
package beandef;

import beandef.Address;

public class Person {
private String name;
private String surname;
private Address address;
/** Creates a new instance of Person */
public Person() {
}

}

package beandef;

public class Address {

private String houseno, street1, street2;
/** Creates a new instance of Address */
public Address() {
}

}
##################################
A good source for learning jibx is http://jibx.sourceforge.net/tutorial/binding-tutorial.html. The above mechanism shows how we can debug projects using netbeans even when there is a need for custom ant tasks.

Saturday, December 1, 2007

The 'Stig' factor - Philosophy

What is Stig factor?
ZEN>>Isolation but observation. Visibility in Invisibility.

Why do I need to know this?
ZEN>> Because Top-gear has this. Because this is the ultimate truth (well a step short of if there is one). Because you asked me. And if you think zen doesnt' involve one thinking of Aston martins, you are wrong. It is always about things like Spider vs. Beetle in the parking lot. I like both of them by the way.

Master explain this in simple English to us 'not so crazy nuts'
ZEN>> Now that you have asked. In this world all entities are related. Some call it 'Butterfly effect'. This association is responsible for all joys and sorrows. Now wise men and truth seekers, who have realized this truth wanted to let others escape the miseries offered by this cruel life. They came up with an brilliant suggestion. That speaks of:
1. Association to disassociation
2. The hardships in breaking all bonds to keep a single bond.

Master but I am a simple programmer
ZEN>> Thats what they said when they came to me. They were simple tv program producers. I still remember that as if it were yesterday.

Master, but who said that
ZEN>> The top-gear chaps of course. They were very concerned about the presenters being more popular than the show. There was a bloke called Gerome clarkson who has nasty prejudice against general motors you know. They wanted some thing which is immune to change. So they brought in Stig. You can realise more about him from http://en.wikipedia.org/wiki/The_Stig . You see there was more than one stig but there is only one stig.

Oh, the zen factor. Things may change but the conception is unique. This what decoupling between modules means
ZEN>> Excellent, now meditate more about decoupling between modules and data bases. One can easily say that data bases are similar to modules with a different avatar. The trick is to store the mapping away from the modules. The modules change but the mapping rarely does. Even if it does you can easily adapt the mapping to the discovered truth

Saturday, November 17, 2007

Autumn in Leeds

Autumn wind in Yorkshire Leeds, cold chill within causes fluttering leaves,
Stands a tree painting tarmac in orange, awaiting the forgotten spring,
She hopes for new life, and the cost she pays is the misery she paints,
A splendid lass baring robes for her new-born, such scene, is it obscene?

Thursday, November 8, 2007

Learning languages

This article is an extract from
http://www.fourhourworkweek.com/blog/2007/11/07/how-to-learn-but-not-master-any-language-in-1-hour-plus-a-favor/



The content copied for ease of lazy few :) Credits to the guy who wrote it




How to Learn (But Not Master) Any Language in 1 Hour (Plus: A Favor)

Filling the Void, Language

arabic-script.jpg
Deconstructing Arabic in 45 Minutes

deconstructing-russian.jpg
Conversational Russian in 60 minutes?

This post is by request. How long does it take to learn Chinese or Japanese vs. Spanish or Irish Gaelic? I would argue less than an hour.

Here’s the reasoning…

Before you invest (or waste) hundreds and thousands of hours on a language, you should deconstruct it. During my thesis research at Princeton, which focused on neuroscience and unorthodox acquisition of Japanese by native English speakers, as well as when redesigning curricula for Berlitz, this neglected deconstruction step surfaced as one of the distinguishing habits of the fastest language learners.

So far, I’ve deconstructed Japanese, Mandarin Chinese, Spanish, Italian, Brazilian Portuguese, German, Norwegian, Irish Gaelic, Korean, and perhaps a dozen others. I’m far from perfect in these languages, and I’m terrible at some, but I can converse in quite a few with no problems whatsoever—just ask the MIT students who came up to me last night and spoke in multiple languages.

How is it possible to become conversationally fluent in one of these languages in 2-12 months? It starts with deconstructing them, choosing wisely, and abandoning all but a few of them.

Consider a new language like a new sport.

There are certain physical prerequisites (height is an advantage in basketball), rules (a runner must touch the bases in baseball), and so on that determine if you can become proficient at all, and—if so—how long it will take.

Languages are no different. What are your tools, and how do they fit with the rules of your target?

If you’re a native Japanese speaker, respectively handicapped with a bit more than 20 phonemes in your language, some languages will seem near impossible. Picking a compatible language with similar sounds and word construction (like Spanish) instead of one with a buffet of new sounds you cannot distinguish (like Chinese) could make the difference between having meaningful conversations in 3 months instead of 3 years.

Let’s look at few of the methods I recently used to deconstructed Russian and Arabic to determine if I could reach fluency within a 3-month target time period. Both were done in an hour or less of conversation with native speakers sitting next to me on airplanes.

Six Lines of Gold

Here are a few questions that I apply from the outset. The simple versions come afterwards:

1. Are there new grammatical structures that will postpone fluency? (look at SOV vs. SVO, as well as noun cases)

2. Are there new sounds that will double or quadruple time to fluency? (especially vowels)

3. How similar is it to languages I already understand? What will help and what will interfere? (Will acquisition erase a previous language? Can I borrow structures without fatal interference like Portuguese after Spanish?)

4. All of which answer: How difficult will it be, and how long would it take to become functionally fluent?

It doesn’t take much to answer these questions. All you need are a few sentences translated from English into your target language.

Some of my favorites, with reasons, are below:

The apple is red.
It is John’s apple.
I give John the apple.
We give him the apple.
He gives it to John.
She gives it to him.

These six sentences alone expose much of the language, and quite a few potential deal killers.

First, they help me to see if and how verbs are conjugated based on speaker (both according to gender and number). I’m also able to immediately identify an uber-pain in some languages: placement of indirect objects (John), direct objects (the apple), and their respective pronouns (him, it). I would follow these sentences with a few negations (“I don’t give…”) and different tenses to see if these are expressed as separate words (“bu” in Chinese as negation, for example) or verb changes (“-nai” or “-masen” in Japanese), the latter making a language much harder to crack.

Second, I’m looking at the fundamental sentence structure: is it subject-verb-object (SOV) like English and Chinese (“I eat the apple”), is it subject-object-verb (SOV) like Japanese (“I the apple eat”), or something else? If you’re a native English speaker, SOV will be harder than the familiar SVO, but once you pick one up (Korean grammar is almost identical to Japanese, and German has a lot of verb-at-the-end construction), your brain will be formatted for new SOV languages.

Third, the first three sentences expose if the language has much-dreaded noun cases. What are noun cases? In German, for example, “the” isn’t so simple. It might be der, das, die, dem, den and more depending on whether “the apple” is an object, indirect object, possessed by someone else, etc. Headaches galore. Russian is even worse. This is one of the reasons I continue to put it off.

All the above from just 6-10 sentences! Here are two more:

I must give it to him.
I want to give it to her.

These two are to see if auxiliary verbs exist, or if the end of the each verb changes. A good short-cut to independent learner status, when you no longer need a teacher to improve, is to learn conjugations for “helping” verbs like “to want,” “to need,” “to have to,” “should,” etc. In Spanish and many others, this allows you to express yourself with “I need/want/must/should” + the infinite of any verb. Learning the variations of a half dozen verbs gives you access to all verbs. This doesn’t help when someone else is speaking, but it does help get the training wheels off self-expression as quickly as possible.

If these auxiliaries are expressed as changes in the verb (often the case with Japanese) instead of separate words (Chinese, for example), you are in for a rough time in the beginning.

Sounds and Scripts

I ask my impromptu teacher to write down the translations twice: once in the proper native writing system (also called “script” or “orthography”), and again in English phonetics, or I’ll write down approximations or use IPA.

If possible, I will have them take me through their alphabet, giving me one example word for each consonant and vowel. Look hard for difficult vowels, which will take, in my experience, at least 10 times longer to master than any unfamiliar consonant or combination thereof (”tsu” in Japanese poses few problems, for example). Think Portuguese is just slower Spanish with a few different words? Think again. Spend an hour practicing the “open” vowels of Brazilian Portuguese. I recommend you get some ice for your mouth and throat first.

russian-alphabet.jpg
The Russian Phonetic Menu, and…

reading-real-russian.jpg
Reading Real Cyrillic 20 Minutes Later

Going through the characters of a language’s writing system is really only practical for languages that have at least one phonetic writing system of 50 or fewer sounds—Spanish, Russian, and Japanese would all be fine. Chinese fails since tones multiply variations of otherwise simple sounds, and it also fails miserably on phonetic systems. If you go after Mandarin, choose the somewhat uncommon GR over pinyin romanization if at all possible. It’s harder to learn at first, but I’ve never met a pinyin learner with tones even half as accurate as a decent GR user. Long story short, this is because tones are indicated by spelling in GR, not by diacritical marks above the syllables.

In all cases, treat language as sport.

Learn the rules first, determine if it’s worth the investment of time (will you, at best, become mediocre?), then focus on the training. Picking your target is often more important than your method.

[To be continued?]

###

Is this helpful or just too dense? Would you like me to write more about this or other topics? Please let me know in the comments. Here’s something from Harvard Business School to play with in the meantime…

###

Odds and Ends:

Please help me break the Technorati 1000 today!

I’m around 1070 on Technorati’s rankings, and it’s killing me. Can those of you with blogs PULEEEEASE register your blogs with Technorati and find something interesting to link to on this 4HWW blog? It would really be a milestone for me and I’m so close! Just breaking 1000 would be enough. If you can find something to link to in the most popular posts or elsewhere, please do whatever you can in the next 24-36 hours! Thanks so much :)

Wednesday, November 7, 2007

Ratatouille - Any one can cook!

Movies have always been an amusing ways of selling dreams. I have recently seen a magic lantern titled ratatouille. It is far from the Oscars, (probably will get one) definitely doesn’t' strain your tear glands nor stain your hankies. Ratatouille is a fascinating way of reminding ourselves the age old art of story telling. Think of the Red-Indian rituals, Neanderthal cave paintings and even beyond to the point where early humanoids were amusing themselves with the primitive usage of oral communication. Pixar and Disney have mastered this art. The art of story telling is no longer a ritual, I feel sorry for that. It lives thanks to corporate exploitation of childish dreams. Who said capitalism is evil :)


The story is about a rodent hero. The one who resembles more like R2D2 than Keanu reaves. The plot is simple. The hero fulfils his dream!. The dream of savouring food in Gusteaus, a french restaurant. The way the story unfolds brings some childhood memories out. Running around kitchen, doing a shelock holmes with the whole and sole intention of finding the hidden delicacies. Aah, good times weren’t' they.

The more reminiscent words I liked were those of the antagonist Anton Ego voiced by Peter O'tole. Ego relives Gusteau’s words 'Any one can cook'. He rephrases the finer nuance and articulately gives out his criticism during at the climax. Anton declares onerous in a tone that undermines Zen masters and Yoda; that a cook can come from any where and not the superficial interpretation given to the words.

The art of oration put together with some fantastic graphics is something one shouldn’t' miss. This is one fantastic package put forth for audience of all ages.

Popular Posts

Labels

About Me

Well for a start, I dont' want to!. Yes I am reclusive, no I am not secretive; Candid? Yes; Aspergers? No :). My friends call me an enthusiast, my boss calls me purist, I call myself an explorer, to summarise; just an inquisitive child who didnt'learn to take things for granted. For the sake of living, I work as a S/W engineer. If you dont' know what it means, turn back right now.