.: Android runnables and iOS code blocks :.

Every programming language has something interesting to learn. The difference between Objective-C and Java is huge, I don't even like to compare them, but when you change your environment you need to know what your languange supports. Many Android developers there are used to Web and Destktop solutions try to think that the same solution can solve their problems in the mobile world. Maybe they can, but if efficiency is a concern, solving is not always everything. The path to excellency requires both efficacy and efficiency.

Anyway, I was going to write about runnables and code blocks. The iOS developers are probably used to code blocks, since they are part of the language and used widely, specially to use the full potential of the GCD. But about Java? In Java we have callables (link) and runnables (link). I will write about executors (link) another day, since they are part of the same package.

In this guide "Designing for Responsiveness" (link), you will learn that one way to avoid an ANR is to create a child thread to perform the background computation that would block the main thread. But you can't do everything in threads. Some of your code needs to execute on the main thread (like invalidating a view) and that's why runnables are useful.

Android Activities have a method to execute a runnable on the main thread called runOnUiThread (link). If you are suffering to make your threads to work, like when you show a Toast it causes the exeption "Can't create handler inside thread that has not called Looper.prepare()", writing it in a runnable and then calling it on the UI thread will solve it.

Also, many code that is basically copy/paste could be better written if enclosed within a runnable. Since a runnable is an object, you can also use them as parameters to other child objects of the activity, much like delegates used in iOS. In Objective C we control how to dispatch code blocks, the queue to use them, if they will execute synchronously, assynchronously, etc. In Java, executors will do the trick. I hope you find them usefull.

.: Design Your Experience :.

Today I want to highlight the importance of a good design and user experience. It is common sense, everybody knows a good UX is essential, but are we really given it the attention it deserves?

To be honest, when I am creating something I do not pay much attention to it. I just do what is obvious to me and focus on completing the task at my hands. I have a plan and I execute it, so the analysis in between is postponed until I begin testing. It is then I start to feel the features as a user and review my work with critical eyes. To shape the product created to fit the user expectations, that's the idea.

You can see the UX evolve in apps you download and that is something time matures. The Google+ app is a good example. In the current version I feel the usability much better than when I first used it. So it is important to make your code fluid. It needs to evolve!

The idea of creating an app and then assume the work is over is to think old style. There is not a "final" release. We need to change constantly and so these squared ideas. I am not saying the first release should be buggy or ugly, on the contrary! The first impression is very, very important!

All iOS developers can find an excelent guide described in this document: (link).

Android developers can also find excelent material here: (link).

This subject is amazingly rich and there are plenty of stuff I still want to write and share, but if you are an iOS developer you should also try to read the Android guide and vice versa. I am developer of both platforms and I learned a lot from both guides. They are really usefull!

These two rich material deserves to be revisited another day and confronted with each other, so see you later!

Showing posts with label guideline. Show all posts