Connecting Groups
Back to SiteGroups!

SpringSters - Sharing a Little

We live in the best of all possible worlds

CleanupStack - Symbian’s partial answer to garbage collection.

Resources are always scarce, aren’t they? I have always wanted someone to take care of the resources I need and use. For instance that book I had borrowed from a friend with a promise of returning in 2 days time. Which despite all my good intentions I still forget to return even after 3 weeks have lapsed. In real life it is still a dream, but in my Symbian life I have found someone - “Cleanup Stack”.

Cleanup stack is a place to store the variables which are not member variables of any class but allocated on Heap (defined inside function). The objects are pushed onto CleanupStack once they are allocated memory. And popped from the CleanupStack after we are done with them. In between if any exception occurs (We call it a “Leave” in Symbian ), the CleanupStack Pops the object and calls the destructor of the object.

Few questions are always popped up when we talk about CleanupStack. Lets try to find the answers for some of them.

Q. What are the different types of Objects that we can push on CleanupStack?
A. CleanupStack has three overloaded Push functions.

    1) PushL(TAny* aObj): We can put any object (void* in C++)
    2) PushL(CBase* aObj): We can put a CBase class object. So it is advised in Symbian to derive your class from CBase. To use the CleanupStack functionalities.
    3) PushL(TCleanupItem aItem): TCleanupItem encapsulates the cleanup operation (function pointer) and an Object with it. That function is called if any Leave occurs.

Q. How to Use CleanupStack to handle the object of a non CBase class?
A. We should use TCleanupItem to put the object on CleanupStack of non CBase classes. Using TCleanupItem we can associate an Object with a function which will be called if a Leave occurs.
Q. What will happen if we put non CBase object on CleanupStack?
A. CleanupStack will call User::Free() for the object. But will not call the destructor. If the pushed object contains data, it’s a memory leak.

Q. What if I forget to pop the items from CleanupStack?
A. We get E32User CBase 71 Panic. You must pop an item before you leave a function.

Q. Suppose I have pushed 100 items onto CleanupStack, do I have to pop all of them manually?
A. Not actually. One of the overloaded PopAndDestroy function takes the count which is number of items to be popped and destroyed.
eg. PopAndDestroy(100);

Lastly, don’t use the “Check” function as it is for debug builds used by Symbian. It can crash your application if not used properly.

Mangospring @ BarCamp Pune 4

Many of us at MangoSpring have been eagerly waiting for BarCamp Pune 4. Anuj, Vishwa, Shivesh, Basant, Ravinder and myself were all in attendance. It was an exciting day, as this was the first public demo and showcase of PurpleTrail, our first big project at MangoSpring. We have been spending a lot of time and energy getting it ready for public use, and we just recently entered it into beta stage. BarCamp was the right platform to showcase it.

BarCamp is not new to most of us. Anuj had already presented in previous BarCamps in Delhi, etc and I have been an organizer for some previous BarCamps in Pune. BarCamp is always a hit, as 99% of the people attending the event are very interested in the technology, unlike other conferences.

I chose a very interesting topic: “Git Introduction”. I have been using Git for the last two months in my free time. We don’t use it at MangoSpring yet, though I hope that will change soon. Overall, I have found Git to be an excellent distributed source control management tool and I wanted to tell others about it.

On the day of the BarCamp, our talks were scheduled for the first and second talks after lunch. The entire morning at the BarCamp was noisy. People were discussing with each other, and it created a quite geeky, techie and enthusiastic environment.

At 2pm, Anuj started his fast, though relaxing, speech. He has prepared slides and explained in detail and how it works? Initially people were listening as they did not have any idea about product. As Anuj started explaining the features, I was seeing “wow” in their faces. Almost everyone listening got excited about the product. As time went by, initial small whispering in the crowd turned into silence. The only talking was Anuj’s voice, and he had captivated everyone’s attention.

Next Anuj moved onto the demo part of the talk, and this turned out to be a big success. As decided, Anuj demoed the web version and most of the clients running (Symbian, J2ME, desktop, WAP). There are two great moments I remember best. The first was when Vishwa was using WAP and the Symbian client to chat with Anuj, who was using the web version. The second was when Anuj invited two guys sitting in the audience to a demo using their mobile numbers. Within no time they received invite SMSs. Both of these were even a “wow” to me, as it was a real world thing happening in front of me. I think that I was even more happy, as I have been responsible for working on the SMS invites portion of the product. It was very clear that our communication platform the power to change people’s daily life. After seeing everyone’s reaction, I am quite sure that Anuj’s talk was the best talk in this BarCamp. Even afterwards, some people told me that they liked the product very much.


After the it was time for my Git talk. The target of the talk was to inspire people to start using Git for their projects. It turned out to be a good talk, and I think I have inspired enough people to consider Git as their source control management tool.

BarCamp Pune 4 was a great success. Hats off to the BarCamp organizers and the presenters. We all are waiting for the next BarCamp which is scheduled to happen in September.

SAHI… Makes the Life of a Tester Easy!!

It was the other day when I was trying to automate a web 2.0 application with WATIR -an open source automation tool for web UI testing, that I was stuck in the landing page of the application trying to capture the sign up flow. It turned out that the sign up required an AJAX call used widely in every Web 2.0 app. Having forced to explore other alternatives for Web automation testing which would support AJAX calls, HTTP/HTTPS, I-Frames and Javascripts, I zeroed in on SAHI – a light weight web automation tool which I found supported all of these and offered more.

Thanks to a bangalorean named Narayan Raman from ThoughtWorks who developed this web automation tool in java and javascript, it made the life as a tester a lot more easier. This tool uses simple javascript to execute events on the browser. Like any other automation tool available in the market, it has the facility to record and playback scripts. Sahi runs as a proxy server and the browser needs to use the sahi server as its proxy. Sahi then injects javascript so that it can access elements in the webpage. This makes the tool independent of the website/ web application.


Sahi boasts of a heavy feature set including in-browser controls, intelligent recorder, text based scripts, ant support for playback of test suites, multi threaded playback, supports external proxy and HTTP/HTTPS, Dynamic applications and AJAX support, URL based script access, ANT support for running test suites, Script refactorable into functions and files and Accessor Viewer for identifying html elements for scripting. In addition to these data driven testing is possible by reading data from excel sheets and working with databases.

Running overnight batch runs are also possible using test suites integrated with ANT. For each test in the suite, the ant target opens a browser, runs the test and closes the browser. The ant target specifies a suite file, say demo.suite.

The syntax of writing the suite file is:

eg.
test1.sah /startPageForTest1.jsp
test2.sah http://www.d2.com/startPageForTest2.htm
test3.sah abc/startPageForTest3.htm

Ant target for Internet Explorer:

< sahi suite="../scripts/demo/demo.suite"
browser="C:\\Program Files\\Internet Explorer\\iexplore.exe"
baseurl="http://serverName/path/"
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
threads="3"
>

Ant target for firefox:

< sahi suite="../scripts/demo/demo.suite"
browser="C:\Program Files\Mozilla Firefox\firefox.exe"
baseurl="http://serverName/path/"
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
browseroption="-profile ${basedir}/browser/ff/profiles/sahi$threadNo"
threads="3"
>

Sahi has a vast follower base appreciating its simplicity and easy to bend features with its JS engine. Sourceforgenet has hosted an online community to support the members/users spread across the globe under help and Open discussions.

Sahi is a free, open source software released under the Apache License Version 2.0 and
hence can be downloaded from sahi.co.in

J2ME platform Limitations and ways around these limitations

I am a J2ME fan but that doesn’t stop me from noticing some of the limitations of J2ME J.This post is about some of the ways/ideas I have found to overcome those limitations.

 

  1. In J2ME as we all know there is no API for sending an email. Such an API would have been of great use when we wanted to send an email through our J2ME application. But if you just have to send an email through a J2ME application you could pass the email subject and body as well as the senders and receivers name to a Java Servlet the Java Servlet will then collect all this information passed to it by the J2ME application and use Java Mail API to send the email to the desired recipient.
  2. There is no way to access the SMS inbox in J2ME this is because the J2ME midlet runs in a sandbox and has limitations on what all operations it can perform.The idea for overcoming this limitation is to have a native program (written in the native O.S.) which reads the SMS inbox and writes to a Local Socket the J2ME application can then read the data from the Local Socket. But this is not perfect solution because we will require different native programs for different devices.
  3. Every mobile device has an SMS port i.e. the port at which the mobile device receives the incoming Messages (SMS) for example Nokia devices receive SMS at port 0. Now for a Midlet to receive the incoming Messages(SMS) it has to listen at a specific port on the device. Now one can send Messages (SMS) to a device using J2ME (i.e. by using Wireless Messaging API) as well as the normal method (without using J2ME).The Messages send using normal method will be received by the receiving device on the SMS port. On the Other hand Message send using J2ME will carry port number and will be send to a specific port of the receiving device. So we require a midlet on the receiving device listening on that specific port to receive a SMS sent through J2ME.This puts forth an interesting question i.e. if we have a midlet listening on the SMS port of the device will it receive both type of message? (i.e. Normal messages as well as message send through J2ME.) I actually tried it out and found that this didn’t happen. I was unable to receive both types of messages on the device when my midlet was listening for messages on the SMS port of the device. So we can say that we can only receive the Messages sent through J2ME when we have a midlet listening for messages on the receiving device. As I said previously there is no way for accessing the SMS inbox in J2ME but what we can do is to have a midlet listening for SMS on a specific device i.e. get the Message before it actually goes to the inbox and we can have our own created inbox (J2ME application created) for storing the Messages received by the Midlet.
  4. We use platform Request method in J2ME for making a voice call. But the problem here is that we really don’t have any way to end a voice call programmatically. The facility such as ending a voice call programmatically would have been useful for situations such as giving a Miscall through J2ME.The problem with platform Request is that it is totally under the native Systems control so once we call the platform Request for making a voice call we have no way to stop this initiation of voice call programmatically. But now the Mobile Telephony API (MTA) (JSR - 253) is released which promises to have more control over voice call initiation and by using this API we can also end a call programmatically. But still no device yet supports or has the implementation for this API.
  5. Many times we would like our applications to provide Text to speech facility but there again because of the limited resources on the mobile device we may not get fast conversion of text to speech. By that I mean that there may be a some time lag between text to speech conversions of each word because of the limited processing power of the mobile device. The only idea I can think over here is to pass the entire text sentence to a servlet and J2SE also has some classes for text to speech conversion and get back the audio from the servlet and simply play the received audio in the midlet.By doing so we are assigning the much heavy operation of text to speech conversion to servlet which will run on some server and will definitely have more powerful resources than that of the mobile.

Watch out for more in the next post J


Memory Management on Mobile Platform

 

When I was a school kid, I never actually worried about the resources I was using or occupying. I always finished my pocket money before the month end. I was wasting a lot of resources and the reason for that I think was that I didn’t realize where the importance and also the source of resources! But after finishing my schools I never remained careless about my resources. I would attribute the change to learning C and C++ in my college. “Isn’t it funny?” JYes, the memory management in C and C++ encouraged me to handle my resources.

Then came mobile platforms in my life. The best platform to learn doing a lot of things with very less resources. Every chunk of memory you allocate, needs a reason to do so. Gives another dimension to your resources handling skills.

In last few years I have come across a few mobile technologies. Started with Symbian switched to Palm OS for some amount of time and then back to Symbian a little bit of Windows mobile here and there for a change of taste for few days. I came across different memory management techniques, ways to handle exceptions. And of course distinguishing features for every platform. For Palm its “Locking and unlocking of memory chunk”. This I could talk about in one of the later posts. This one is about my first love Symbian and the bunch of features that distinguish Symbian

Two of the Symbian features I like most are:

  1. Two phase construction
  2. Cleanup stack

Two phase construction:

How do you feel when you just start to construct something and it fails? Some things don’t happen as per the expectations, it’s failure on the planning side. Lets take an example: you start building your house and during construction you notice that the carpenter you booked for your furniture didn’t give you proper estimates for resources and your construction fails .. or at least gets delayed for few weeks or months. But in this scenario you can recover by finding another carpenter. But while programming what if the code in your constructor fails? Lets take an example -

class Person

{

char* name;

char* surname;

public:

// constructor and destructor

Person();

~Person();

}

Now let’s say we allocate these two member variables in a constructor as follows:

Person()

{

name = new char[100];

surname = new char[200];

}

Now the allocation for “name” goes well according to plan. And due to unavailability of a free 200 bytes the allocation for “surname” fails. Now what will happen to the “name” which is already allocated? Its orphaned and finally a memory leak in my application. The constructor of any class should not throw any exceptions ( Leave in Symbian ).

According to me, the best way to handle this situation would be a Two phase construction. It’s a method of creating an object in two phases. First phase would be a constructor and other is say “Construct” method. Let’s take above example class and add a two phase constructor to it.

Class Person

{

Person();

bool Construct()

public:

static Person* Create();

~Person()

}

Person* Person::Create()

{

Person* me = new Person();

if(Person == NULL)

{

return NULL;

}

if( me->Construct() == false)

{

delete me;

return NULL;

}

return me;

}

bool Person::Construct()

{

name = new char[100];

// check for allocation

if(name == NULL )

{

// allocation failed

return FALSE;

}

surname = new char[200];

if(surname == NULL )

{

// allocation failed

// delete previously allocated memory

delete name;

name = NULL;

return FALSE;

}

// everything is successful it means my object is properly allocated

return TRUE;

}

 

This technique of allocation of memory is very impressive for mobile platform because it handles the failure of object construction. I would love to see non wireless platform adopting similar techniques to ensure cleaner object construction.

Be back with the next post on “Cleanup Stack” soon, remember thats other feature I like the most in Symbian.

- Kiran

Comted, barcamp & me: the way we “push” things around at MS

The much anticipated Barcamp 3 was a great success! Many of us springsters gathered at the PSPL Campus to represent MangoSpring and show others why it is one of the best technology companies in Pune.

Our very own Springster Anil was one of the organizers of the Barcamp. He did a great job juggling back and forth between his event organization duties and joining the fun with his fellow Springsters. The sessions for the day were well coordinated in advance, and lots of people showed up to share and gain knowledge. The only two lady speakers at the barcamp were my fellow Springster Anjali (our happiness manager) and myself. Our sessions were slotted for the afternoon, which gave us both the opportunity attend the other presentations with our fellow colleges and soak up as much from the other presenters as we could.

MangoSpring’s time to shine started in the afternoon with Anjali speaking about “Organization 2.0″. It was a very healthy discussion on how we are building “culture” at MangoSpring. For more on this, see Anjali’s blog below. Following Anjali’s presentation, we gave a glimpse of the technical work done at MangoSpring. I was then let loose to talk about one of the technologies that we use here- “Push Technology-Cometd”.

To briefly explain “Push Technology-Cometd”, it is an alternative means for data delivery to the browser. Our classic web paradigm of “Pull Technology “gives us some hiccups when it comes to real-time based or multi-user applications. In a normal web-based application which needs to show fresh data, we expect the client to request (poll) the server at frequent intervals in time to maintain the freshness of data. However, this leaves high chances of the user seeing stale data for some amount of time before the next polling cycle kicks in. “Push” addresses this problem with its completely opposite approach. Using “Push”, the client initially opens a long-lived connection with the server and registers its interests in the specific channel it wants. From then on, the server
pushes data and updates the respective client as and when the data changes. Using this technology, the freshness of data is maintained for the end-user without any user or periodic browser intervention.

Cometd is a project which implements this technology and has drafted a spec called Bayeux, to make implementation of Push Technology more standardized and
developer friendly. The Cometd server implementation which we work on is being written entirely in Java. Many more details that I talked about in the presentation are captured in the slideshow uploaded with this blog.

At the end of my talk there was a good Q&A session which reflected the interest of the audience in the session. This was great for me, because it gave me an opportunity to get my thoughts across. Afterwards, many people also had specific implementation questions and questions about multiple server implementations of Cometd.

After the presentation was over, it was a great feeling knowing that I shared everything that I had set out to. It was also great to have our fellow Springsters there for support and motivation. The cheers from Abhinav, Anil, Anuj, Basant, Hari, Nilesh and Rana were much appreciated!

When all was said and done, the end of Barcamp 3 Pune left the Springsters with enriched knowledge and greater confidence ….and don’t forget the smiles on our faces!

- Isha
Click to download the presentation

What is Felix? - Clue #1

A lot of people have been asking us about Felix, the codename for MangoSpring’s flagship product. We have been very tight lipped about it, but have decided to loosen up a bit as the team gets closer to doing the first alpha release. The clue below should point you in the right direction. Big thanks to, our own, Avinash for the great t-shirt design!

tshirt front

tshirt back

Any ideas? Send your guesses/comments to feedback@mangospring.com.

BarCamp 3 in Pune

I have been loosely associated with BarCamps from its start in India back in early 2006. The first BarCamp happened at Delhi and well AJAX, ROR, Web 2.0 were then not mainstream as they are today. I had spoken on contextual flow between mobile and PC. Read here and here

Since then I have been to BarCamps in Bangalore, Pune, Mumbai. Spoke on different topics and given product demos.

And now its BarCamp3 in Pune. A lot of common names on the wiki already.
We at MangoSpring are an active participant and supporter of barcamp, MoMo’s ( Mobile Monday) and the likes. We hope to be present their in strength. To learn, to see, to hear and of course to share.

Quiet a few of us are looking forward to give sessions. Anjali ( our Happiness Manager) is eager to talk about what she calls ” Organization 2.0″ - must say she has become quiet good at using these buzz words :-) She believes that organizations need Happiness managers and not HR managers. Also her ideas on ‘Naked organization’ and flat structure inspired us to come up with TaskBin.

I myself shall talk about how communication has evolved over the internet from bulletin boards to email, from IM to sms, From scraps to twitter. We at MangoSpring our working on our stealth product Felix in the space of communication and messaging. We believe that true innovation in this space has only just begun to happen and are glad to be at the forefront of it.

Hari is a changed man. From Java fanatic to Rails convert in 6 months. He wants to share his experience with fellow developers at BarCamp and Isha is all set to show how push technology on browsers is here for good and show case Cometd implementation.

More on BarCamp 3 as it happens.

Technologies @ MangoSpring

Few of you asked if you could get a big picture view of what technologies we use at MangoSpring and how different roles/career profiles fit in. So, here you are…the diagram below does a decent job of capturing how different technologies are used at MangoSpring to bring a seamless user experience across platforms and devices.

Technologies @ MangoSpring

Hopefully this gives you a good idea about some of the major technologies we play with at MangoSpring at different levels. Contact us at info at MangoSpring.com for more information.

©2007 - 2008 MangoSpring. All Rights Reserved.