Playing with Android SDK – Part 2

After getting to know the onTouchEvent() a little better I decided to figure out the coordinate system of the Android graphics system and put in some movement logic. I thought I needed to figure out how to use the velocity tracker in order to do this, which is a very cool class and its a little different approach than other graphics systems I have coded to in the past.  Once I got the concept, I was able to capture where the touch was started and where it ended along with how fast it was.  The key is to coordinate the MotionEvent.ACTION_DOWN and the MotionEvent.ACTION_MOVE event types.  Once I got the concept of how to use these events the code became much easier and I actually didn’t even end up using the velocity tracker!

Here is a basic system I created to figure out where the touch happened and as the square is dragged across the board I calculate what square the touch is over by highlighting the square in blue.

Dojo and Duck Typing

JavaScript is powerful yet unruly language but through creativity, standards, and best practices you can control the unruliness. Dojo has put a lot of this into consideration and the topic I am writing about today is a technique called Duck Typing.  In the book, Dojo The Definitive Guide, there is a chapter dedicated to utilities and within that chapter there is a section on type checking.

“Duck typing is based upon the saying that if it walks like a duck and quacks like a dck, then its a duck.”

Dojo comes with a bunch of methods to help with this, like isString(), isArray(), isFunction(), isObject(), isArrayLike(), isAlien().

These kind of functions can make your code a lot more safe if you expect a certain type in your function and use them to test that you received what you expected.  Unlike in Java where you can use actual interfaces and class types, you do not have that in JavaScript.

Online Interviews with the industry best

The book I have been blogging a bit about lately has a site with a section under posts where the actual interviews with the industries brightest are posted.  Each  interview is a part of a chapter in the book, I believe Sam will be posting them all eventually.  I think this is an interesting concept and I found the actual recording more interesting than the written interviews in the book because I got to hear their voices.  I do think the textual versions of the interviews are very good in that you can reference them but I really like hearing the voices.  Maybe in the future there will be some sound chip on the page where you can listen to it.  It would be cool if the eBook version had the audio attached to the interview pages – hint Sam…

[poll id="11"]