Friday, January 28, 2011

Rhomobile talk in Pune Rails Meetup

Today Akshat and I got a chance to speak about Rhomobile in Pune Rails meetup. It is good to see that lot of people are showing interest in Rhomobile. 
You can download PPT and code which we showcase from following link :
Code on github :

Monday, January 24, 2011

Improving performance of your Rhodes application #Rhomobile

I am listing out the way to improve the performance of Rhodes application:
  • Set MinSeverity=3 in rhoconfig.txt for production. Otherwise it will log all your activities and will affect your performance.
  • Set bb_loadimages_async=1 in rhoconfig.txt. In this mode next page opens, while the images are being loaded in the background 
  • Minimize the possible external files like CSS and Javascript. If possible include these file in layout.erb. 
  • Use Fixed schema instead of Property Bag if you schema is fixed and not expected to change. You can refer this link to understand it better
  • Avoid using XML as they are slow, instead try use JSON.
  • Try using Rho JSON for parsing, if you have been using JSON. Rho JSON will minimize your sync time.
        parsed = Rho::JSON.parse("[{\"count\":10}]")

     You can refer following link to dig it in detail:

Courtesy: @adamblum and akoc :

  • Bulk Sync :  Bulk sync will make huge deference in performance while syncing from rhosync.

  •   Push : Rhosync Push API also give a edge on performance while syncing.

P.S : If anyone can suggest any other ways he is welcome to comment on the Blog :) 


Thursday, January 20, 2011

Difference between Propery Bag and Fixed Schema #Rhomobile

Rhomobile provide a mini ORM called Rhom. It is similer to Active Record of Rails but with less features.It provides a high level way to make the local database easier to program. That database is SQLite on all platforms except BlackBerry where it is HSQL.  

We can choose to store data in two way Propery Bag or Fixed Schema

Property Bag
All the data is store in stores in single table. Property bag is a db table which contains object id/attribute/value triplets and therefore set of attributes for each object is arbitrary.

  • It is simple to use, no require for specifiyng attributes before use
  • we don't need to migrate data if  we add/remove attributes
  • Size is 3 times bigger than fixed schema
  • Slow while sync

 This is how model look for PropertyBag:

class Employee
  include Rhom::PropertyBag

  # Uncomment the following line to enable sync with Employee.
  # enable :sync

  #add model specifc code here

Fixed Scema
Fixed schema is a regular db table with fixed set of columns (attributes)

  •   Smaller size, you can specify index for only required attributes
  •   Faster sync time then Property bag
  • You have to support all schema changes
 This is how fixed schema model looks :

class Employee
  include Rhom::FixedSchema

  # Uncomment the following line to enable sync with Employee.
  # enable :sync
  set :schema_version, '1.1'
  property :name, :string
  property :age, :string
  property :company, :string
  property :address, :string
  property :gender, :string
  property :salary, :string
  #add model specifc code here

Note : You have to reset database if you change the property

When you use Fixed Schema model application developer is responsible for sql schema. So when you add or delete some properties or just change app logic you may need to perform data migration or database reset.
So if you have to add a column in a table we have to add a property and then reset the Device.

To create a index in fixed schema we will write following line in model :
index :by_name_tag, [:name, :tag] #will create index for name and tag columns  

To create a primary key in fixed schema we will write following line in model :
unique_index :by_phone, [:phone]

Choosing in between PropertyBag and FixedSchema depend on you requirement. 

Monday, January 10, 2011

Disable status popup in Rhomobile

If you want to disable popup then add this line before dosync :

And If you want to show popup then add this line before dosync :

By default  :
Blackberry – Popup is enable
iPhone – Popup is disable
Android – popup is disable