RSS

Tag Archives: why

Kotlin for Android (I) Why I love Kotlin


If there is only one sentence to describe Kotlin, it would be: “Kotlin is great”!

You will not appreciate the beauty of it if you do not suffer from the repetitive, boilerplate coding in java. Let’s see an example first.

Consider you have two classes, as shown below, they do the same thing, interchangeable, exactly the same in terms of functionality, which one do you choose? Left or right one?

  image  image

The left one is java implementation, and the right, Kotlin.

This is a real example that I encountered in developing an Android App. The App tries to get the new questions on StackOverflow site: Open the link below in your browser to see how you can get the json from StackExchange API:

https://api.stackexchange.com/2.2/questions?site=stackoverflow&key=JE1srJAZi8)AoOEHcHUWdg((

You will be presented a similar json as below:

stackoverflow-questions

In order to display a list of such questions in Android views, I need to deserialize this json string to a POJO (Plain Old Java Object) representation. To avoid hands dirty,  we can go to http://pojo.sodhanalibrary.com/ and paste the json string to get the POJO class:

Read the rest of this entry »

Advertisements
 
Leave a comment

Posted by on June 27, 2016 in General

 

Tags: , , , , , ,