Sunday, 21 February 2010

The war in your pocket, the Mobile World

Shortly after the announcement of Apple’s long waited iPad, GSMA 2010 heated the mobile arena much more. It is quite clear that the kingdom of iPhone is in great danger unless they have new suprises.

Here are some key points;

Android, should be the most promising system on the market. There are over 100 android devices announced either available or hit the shelf soon. HTC announced new models based on Nexus One and Hero. One of the greatest advantage of Android is the full flash support. So far it seems like its the most compatible and mature system for the flash player. Also android offers a quite open platform and easy development for Java/JavaME developers. Google has handled the most important problem, the hardware variety quite well. Android seems to be performing quite compatible and customised on different handhelds which was a key point against iPhone since Apple does not need to face such an issue as the only hardware provider. Also Google’s attempt to attract developers to build apps even much before the devices exist, is really paying back now.

Windows Phone 7 series, looks nice and modern. Integration with current Microsoft tools is a plus but i still wonder if it can wipe the bad memories of the previous Windows Mobile systems. Microsoft should also be worried about that since the name WM totaly changed to Windows Phone. XBox Live could be a nice catch but not sure if it will be enough to attract any gamers. The user interface look very modern and sleeky. Microsoft has done quite a lot in terms of user experience but I’m not sure if the animations and transitions are really well designed. To be honest they look nice at first look but for daily use I feel they would be a bit slow and exaggereted. Also they need hardware support which seems like it would not be problem but in terms of nice stunning designs that could become a problem against iPhone and Android. One more questions is even though Windows has been around much longer than Android, iPhone it lacks the application variety and a centralised app store which their rivals have.

IPhone, is the quite leader of the modern smart phone market. Besides the handhelds and OSs they also rule and make good money on the applications. IPhone had a minor update with 3Gs but I really feel they are getting a little outdated with the upcoming devices against Android. But still Apple is always full of suprises so there might be a very unexpected upgrade which would change the current situation. Well even for the current models, iPhone offers easy of use, sleeky and a trendy device against its rivals. Also Apple now has a huge mobile device which is called iPad whose destiny would be interesting to watch.

Samsung have their own OS, with Java support and trendy models. I am not sure if they can offer the same rich use experience but it is sure that they are quite fast to implement new stuff.

Palm has been left out of my scope for a long time, however, now I have an eye on them after the move of Sun’s Josh Marinacci. It would be nice to use his experience on JavaFX to bring better user experience to Palm.

Seems like 2010 will be a very big challenge for mobile world. Flash will be out soon with Flex and ability to export IPhone apps even though Iphone does not have a flash player, JavaFX offers easy mobile development, Android is has a solid OS now and they are taking nice steps for user experince, animations, transtions and they have a nice app store. Microsoft finally have a modern OS (although they are about 2 years late, actually I find it hard to understand they should know the advantage of being early on the market from their XBox experience), Apple (probably) making secret plans to keep the advantage of being unique.

Let’s wait and see..

Sunday, 7 February 2010

Objectify; an easy way to use Google Datastore

If you had watched Larry Ellison on Oracle-Sun Strategy Update webcast, he was making fun with the word "cloud", telling thats just a new name for something they had been doing a long time. However same time Oracle's web site was announcing Oracle Cloud Computing Forum.

Whatever name you call it, clouds are popular and when it comes to clouds Google App Engine is an exciting one. Google's approach to clouds is not much different from Apple to computers, end users should not be involved to administration and internals, things should be simple,  easy to use but yet still trendy. Google App Engine supports Java, has an eclipse plugin, built on Google's famous database approach the BigTable, comes with GWT which offers easy web development and a simple, easy to use database supporting JPA/JDO. Still datastore might become a little confusing since it is not a full relational database and also the low level API might become confusing.

This is where objectify takes stage, its The simplest possible *typed* abstraction to the Google App Engine datastore. Objectify comes with a nice wiki, which includes examples, and documentation.

To try objectify first you need to install GAE plugin to eclipse, next you need to download one single jar file. The following would not be adding much to original wiki, but can be used as a summary and shows what i tried on objectify.

I assume you have GAE plugin running on eclipse, if you don't, visit to install the plugin, and while you are there don't forget to register an account.

Lets start with creating some entities;

public class Course {
@Id //id fields can be long, Long or String. Only Long automatically generates keys when it s null
Long id;
String name;
String branch;
//add getters and setters

Now lets create another entity within relation to first one;

public class Student {
Long id;
String name;
OKey course;
//add getters and setters

Since our entities are ready, lets start playing with them. To use our entities on datastore via Objectify, first thing we need to do is to register them. Lets create a service class to perform data operations.

public class SchoolService{
public SchoolService(){

Now lets write some code to test the datastore.

public boolean createCourseWithSomeStudents()[
Objectify objectify=ObjectifyService.begin();

//create a course
Course course=new Course();
course.setName("Beginning GAE Programming");
course.setBranch("Cloud Platforms");
objectify.put(course); //persists our entity and sets a generated id

//Lets create some students for our class
Student student=new Student();
student.setCourse(new OKey(Course.class, course.getId());

//just add as many to same course...
return true;

Entities with null assigned Long ids will automatically assigned autogenerated values. If you set this id to your object same put operation would work as an update. Since out datastore has some data, now it is time to query.

First lets write a method to list all our available courses.

public List getCourses(){
Objectify objectify=ObjectifyService.begin();
//Create a OQuery for Course class without setting any filter
OQuery q = ObjectifyService.createQuery(Course.class);
List courses = ofy.prepare(q).asList();
return courses;

This should return all persisted courses (which should be one if you had just followed the example) as type safe list. Since the course is retrieved we can query for the data related to it. Too add a method which queries the student objects which have relations with the course we retrieved, OQuery provides filter methods.

public List getStudentsFromCourse(Course course){
Objectify objectify=ObjectifyService.begin();
//get the OKey of the object
OKey courseKey = new OKey(Course.class, course.getId());
//prepare a query for student
OQuery q = ObjectifyService.createQuery(Student.class);
//add our course key as a search criteria
q.filter("course", courseKey);
List students = objectify.prepare(q).asList();
return students;

Instead of using asList method there are several other methods such as, asIterable and asSingle (nice if you are sure to hit a single result).

Objectify may not be perfect on all aspects but its quite nice and easy, to use the Google App Engine Datastore which may not be very friendly with JPA/JDO all the time. The current documentation is not bad and quite complete and honestly I find it much clear than GAE's JPA/JDO documentation.

Also do not forget to check best practices which has nice tips and can save you from pitfalls like not using static initializers for the entites to register themselves to objectifyService.

By the way, for a quick test just extend HttpServlet in our service class and add a doPost method calling the methods you want to test.