Wednesday, March 10, 2010

J2ME jar size

If you build application, sooner or later you will hit J2ME jar size problem. if you use libraries like LWUIT, you start with 90KB. Then you add resources (images, strings) of 130KB. And then your app takes few more hundred KBs. This will hit you when you realize that some of the phones like MOTO RAZR will only support 400 or 500KBs app sizes and some phones will even restrict you to 200KB.

Statment level LOC, Method and Class are three variables that we played with. Keeping LOC and class constant we changed methods. Here are the numbers,






MethodsJar Size (Bytes)Delta for additional method
11301
2132019
3133919


Keeping LOC contant, we added classes (and in first three additions a new method also came about)








MethodsJar Size (Bytes)Delta for additional method
11301
21738 437
32167429
42605 438
52913308 Empty class added


So, for every method add a 19B and every class add a 308-400B hit is there.

Here is the class that we were playing with,

public class HelloWorld {
public void say()
{
System.out.println("H");
System.out.println("e");
System.out.println("l");
System.out.println("l");
System.out.println("o");
}

}

For methods we had,


public class HelloWorld {
public void say()
{
System.out.println("H");
System.out.println("e");
System.out.println("l");
System.out.println("l");
System.out.println("o");
}
public void say1()
{
System.out.println("W");
System.out.println("o");
System.out.println("r");
}
public void say2()
{
System.out.println("l");
System.out.println("d");
System.out.println("!");
}

}

Thursday, May 7, 2009

Is Resource view (REST) as powerful as Object view?

We are comfortable with object view of the world. Everything is a class and each class has data members and method members and has relationships to other classes. In plain English we have nouns and verbs. If you are user of a object API, you get the right noun instance and call the verb on it - get the duck instance and say "fly". We can model bank domain to rocket domain using this.
Modeling this as a service as in SOA or method call as in RPC is also straightforward. Calling a method on a remote object is possible (CORBA). And that in turn is equivalent to a method call which has object identity as an argument.
Is Resource view equally powerful? I thought a service "SendEmail" might be tough to be seen as a Resource that has a universal interface (HTTP method). http://www.prescod.net/rest/restmail/ shows that this is possible. Does it look contrived?
Well, we could analyze this with two approaches. By making the whole world look like resources we are converting a set of "nouns and verbs" to fixed few verbs and lots of nouns. I as a human can do many things - run, sleep, think etc. How do i reduce it to nouns? One way is state model approach - i see things as states and each state is addressable by URI. So i have a running man, sleeping man etc. Is a state a resource? Not really.
Another way to look is that we are only interested in representation and transfer of representations between client and server. So you get representation of a resource - which is a man. And you update the resource's representation on client, say you change it from running to sleeping and then you call update onto the resource again. It is like you take a toy look at it and turn the switch on and put it back - the toy starts playing. So any object model can have an equivalent resource model where object are resources, data members are part of representation of object and method calls are triggered on server side by client modifying the representation of object and updating the server. This has an integral part, serialization of object into an representation that can be shipped to far away place and a change could be applied with a returning representation.
On a broader view REST looks like shopping experience. You go to a shopping mall and all shops are resources. You hop from one to another - your state transfers, resource stays where they are and you only get a representation of resource (godown is the actual resource).
It also looks as if REST is remote object protocol - except that methods are not called directly. They however could be effected by state change. How does document style services differ - well, they look more closer to REST than RPC style services. The equivalence is when there are seven kind of services - Get, Post, Head, Put, Delete, Trace and Option.
This again takes me to LISP and turing machine. Anything can be modeled by a simple list or a set of read/write/mark instructions. My faith in higher level ideas like REST is strengthened.

REST is primarily for remote communication. One will not implement their business logic entirey using just resources - it will be object model. REST representations are photographs of these object model - one object at a time.

Monday, May 4, 2009

FREE stack

Flex, REST and Enterprise backEnd

EE could be JEE or Jersey based REST provider. Back-End programming language is Java.

What one should be aware of:

1. Flex doesn't support PUT, DELETE. So if u try hooking xmldb as backend and Flex front-end it will not be out of box.
2. Flex doesn't give u status code back in HTTP response
3. Your major concerns would be how to integrate new app built on this stack with existing infrastructure - especially identity management.

What are some of the pluses that stand out

1. With flex you no longer worry about lower level UI aspects. It is far more faster to develop UI with flex. And it is building bridges with other technologies for backend.
2. With REST you are ready for a developer platform right from the begining.
3. With REST you are web ready. You can take on scale, performance, mashup etc easily.
4. With Java you have a proven platform for doing enterprise application backend.

Sunday, April 19, 2009

Sudoku and Architecture creation

Here is how i solve Sudoku puzzles. I look at the whole problem and try to see from my memory if i have ever seen a pattern like this or even a sub-pattern. If i find one then i try to see if whole or part of or learning from the old solution could be used. In either case i proceed as below. Let me call it pattern approach.

The simplest of sudokus have a weak part of the problem. If you get that part and solve it, suddenly the whole sudoku solution comes up on its own like a thread that has been pulled from a woven cloth. Sometimes it is multiple threads, so when u take out one thread, you have to find the start of another thread and so on. Same might be true when u are solving a huge set of simultaneous equations with pen and paper. You look for equation with least variables or some peculiar form that has clue in it. Looks like a detective approach. Let me call it weakest part of problem approach.

In some of the harder sudokus author removes all the starting points. One can however find a starting point that needs assumptions of a small part of initial solution. One starts, tries it and backtracks on findind deadend. Then starts again with a different assumptions. Let me call it trial and backtrack.

Given the problem specification (i.e. all requirement and context analysis done), an architect tries a similar approach:

1. Pattern approach
2. Weakest part of problem approach
3. Trial and backtrack approach

Sunday, March 8, 2009

Is this online site alive

I have tried lots of social networking sites. But it was only today that i tried plaxo. Here is the first experience on this site. The first wow on a social networking site is finding people you know who are there. Connecting them brings the site alive. What differentiates an online site from a remote data store and remote application delivery site is that it connects with other's data.
There was one more thing that brought more life to plaxo. It collected my internet footprint - it searched blogs and got entries authored by me. Ofcourse a different UI adds to all this.

Monday, November 17, 2008

Capabilities that an Architect picks up

One starts of as a learner of technology
One masters programming
One masters problem solving
One gets hang of technologies - to know trends
One if able to apply technologies to solve problem
One is able to conceptualize big (in scale) solutions
One then learns to develop a plan for achieve solutions - what is the order of building pieces
One learns to bring in business into picture - buy vs build
One learns to adjust plan as business situations change
One learns how to lead execution of an architecture
One learns how to sell architectural proposals
One learns how to teach
One learns to lead and facilitate - let everybody realize their potential

My belief is that there are more of such learning steps... rest of mountains in the journey would be visible once one crosses these ... i am still stuck in one of the mountains ...A lifetime is not enough to master all this ... that will keep the excitement in the journey!

Troubleshooting JBoss HA

JBoss HA relies on JGroups for communication. It is very easy to work with, but if it doesn't it gets little difficult to troubleshoot. This is what i realized last week when i tried to set it up on two machines. Here are the steps you can follow if you are stuck:

1. Check whether multicast works - http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Clustering_Guide/4/html-single/index.html#id3016498
Want to read some theory on multicast - http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Multicast-HOWTO.html

2. Check if JGroups is able to establish communication channels - http://myt.ag/URLWeb.aspx?email=steve%40fooworks.com&url=http%3a%2f%2fwiki.jboss.org%2fwiki%2fWiki.jsp%3fpage%3dTestingJBoss&sn=

3. Enable logging in JBoss to see more info - http://www.jboss.org/community/docs/DOC-9164

4. Make sure that you are not booting JBoss with -b 0.0.0.0. Give IP address of machine instead of 0.0.0.0