Sunday, May 30, 2010

Robot In Space (RIS) - Introduction

I played a role of Robot this weekend...

I was think of a concept about designing a Java wrapper/representation of real time Robot. After spending some time I thought let's write it using OOP (Object Oriented Programing). After thinking for a while I started writing few classes and interfaces and very soon it became very intresting and I thought that I should share my work with you all.

Still I am not completely done with the idea I have. I am still improving the code and re-factoring it. I have already created a project on Google-Projects but, still I have not uploaded the code. After a satisfactory re-factoring I'll upload it and I'll update my blog about it or you can follow me on twitter for update.

At the moment I the thing which I can share with you is a simple introductory document. For more information please download the PDF from here.http://robot-in-space.googlecode.com/files/Robot%20In%20Space-Introduction.pdf

Sunday, May 16, 2010

Cloud Computing: emerging frameworks comparision and fight !

We have been hearing a lot about cloud computing these days and lot of companies are coming up with various frameworks and strategies for cloud computing. The main thing which I am afraid of is "no standard" behind the cloud computing and every other developer is building whatever he likes and the way he likes. This will present a serious problem to developer community in coming days, how??

1) It'll be very hard for developer to understand what cloud computing is? And the problem is "no standard" (I don't like complaining, but its true).
2) Every framework provides its own concept which makes developers life harder.
3) Integration will be one of the areas where developers will face a big problem while communicating with applications deployed in heterogeneous clouds.

Lack of convention and standards will need to address in coming days so that the buzz word “CLOUD COMPUTING” can live for a long time (at least in developer community). Here is one link where I found someone (somewhere) doing something in the direction of standards http://www.itnews.com.au/Tools/Print.aspx?CIID=174893&utm_source=twitterfeed&utm_medium=twitter

A nice comparison between to famous frameworks (Hadoop Vs GridGain):
http://wiki.apache.org/hadoop/HadoopVsGridGain

http://gridgain.blogspot.com/2008/05/gridgain-vs-hadoop-continued.html

Saturday, May 15, 2010

Flex: Loading external properties file

Flex is a nice platform which provides many out of box feature and that's why more and more Java developers are bending towards it. When I started using flex very soon I started comparing it with Java features. Java provides a features where you can externalize your application configurations in to a configuration (.properties) file external to application, by doing this we can change the configuration without actually changing the application code. Flex is also having same concept where you can externalize the application configurations in to a file. Here is a sample action script class using which you can load a (.properties) file in Flex application. 

public class PropertyFileLoader
  {
    [Bindable]
    private var VARIABLES_URL:String = "default.properties";
    [Bindable]
    public var vars:HashTable = new HashTable();
    private var urlReq:URLRequest;
    private var urlLdr:URLLoader;
    public function getValue(key:String):String
    {
      if(key != null && key.length > 0)
      {
        return vars.getItem(key);
      }
      return null;
    }

    public function PropertyFileLoader(fileName:String) {
      /* Initialize the two ArrayCollections objects with empty arrays. */
      VARIABLES_URL = fileName;
      /* Initialize the URLRequest object with the URL to the file of name/value pairs. */
      urlReq = new URLRequest(VARIABLES_URL);
      /* Initialize the URLLoader object, assign the various event listeners, and load the specified URLRequest object. */
      urlLdr = new URLLoader();
      urlLdr.addEventListener(Event.COMPLETE, doEvent);
      urlLdr.load(urlReq);
    }

    private function doEvent(evt:Event):void  

   {
      switch (evt.type) {
        case Event.COMPLETE:
          if(vars.length <= 0)
          {
            var ldr:URLLoader = evt.currentTarget as URLLoader;
            var lines:Array = ( ldr.data as String ).split( "\n" );

            for each ( var line:String in lines ) {
              var pair:Array = line.split( "=" );
              vars.addItem(pair[0], pair[1]);
            }

             break;
          }
      }
    }
  }


And this is how you'll use above class to load the external file (sample.properties) and use the configuration values in you application: 

sample.properties file: 
service.endpoint=http://surya:8080/erp/messagebroker/amf

Code to access above property:
public var configuration:PropertyFileLoader = new PropertyFileLoader("sample.properties");

public var configValue:String = configuration.getValue("service.endpoint");

Apart from above code we also need check sandbox security options which should allow flash player (flex) to access the sample.properties file. For more information follow this link http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html and update your sandbox security options accordingly.

Saturday, May 1, 2010

Flex Error: Call to a possibly undefined method

Hi,

I spent a lot of time finding why I am getting "Call to a possibly undefined method" even though it was defined in my class. I came to conclusion that :

"Never ever declare a variable with a name similar to namspace/package name."

Here is a nice supportting example:

1) Lets say you have a Flex application which contains a Main.mxml at root.
2) Create a class HelloExample.as in a package config (i.e. config/HelloExampl.as) and declare a function sayHello() which just says "Hi".
3) Declare a varibale with name "config" in Main.mxml and try to call the method sayHello() and you'll get this error.

There are other cases as well when you'll get this error, but I thought it is worth mentioning here because its not easy to find. I hope this will help some one.

Get in the Vibe with Copilot Agent: Supercharging Your Coding Flow

Have you ever felt "in the zone" while coding? That feeling of seamless flow, where the code practically writes itself? That's...