Wednesday 29 January 2014

According JavaScript The Respect It Deserves

One common misconception and practice among developers is the assumption that we can hop into the world of JavaScript and start writing useful code simply because we already know how to program in C,C++,Java or C#.

We learn how to declare variables using the var keyword, how to get handles to DOM elements with
document.getElementById("id") or getElementsByClassName("className") how to dynamically manipulate the styles attached to DOM elements and finally register event callbacks to be invoked for specific browser events.

The recent outburst of awesome JS libraries such as Angular JS, Backbone JS, Knockout JS, JQuery, D3 ect proves the power of the world's most used language, JavaScript. JavaScript is the engine that powers the web of today. It's the reason for the responsive web apps we enjoy today.

The power of JavaScript goes beyond mere DOM manipulations. It is a very powerful language when given the necessary respect. Though it was released prematurely by NetScape during the browser war era, JavaScript shipped with some really good stuffs. Despite the nasty side of JavaScript, it does more than simply manipulating DOM elements and handling of callbacks. The good sides of JavaScript is the reason why it was the best fit for developing Node JS, a server side JavaScript engine for implementing highly responsive, non-blocking and near realtime web apps.

JavaScript is an Object Oriented Programming language with constructs similar to classes, constructors and inheritance as we know from other mainstream OOP languages like C++, Java , C# etc.

For most of us, our learning of JS never comes to this street of OOP. JS is really cool when used from the good side.

To further build your understanding in JS, I recommend these books which I recently bought from leanpub

1. JavaScript, The Good Parts
2. Principles Of OOP in JavaScript

And finally to learn more client-side JS you can try

3. The Definitive Guide To JavaScript.

Isn't it time to say hi to JS?

May this year kick last year's ass!

Tuesday 28 January 2014

Groking The Android Emulator

The Android SDK offers a bunch of mouth-watering tools to developers to increase their productivity. Most of these tools are second-to-non when compared to the tools provided by other rival mobile platforms such as Apples iOS (XCode).

One of the most outstanding tools in the Android SDK is the Android Virtual Device, A.K.A Emulator. In this post, am gonna show you how to have fun with the Android Emulator. I assume you already have your SDK setup and some ADVs created.

Now run an instance of the emulators shown in your AVD Manager.
Each instance of the emulator is bound to a port number which is shown on the title bar of the emulator window. My emulator's port number as at the time of this post shows 5554. (Yours may be different anyway)

Now, let's connect to the running emulator via telnet.
Open your terminal or command prompt and execute the following command

telnet localhost 5554 (Replace 5554 with the port number shown on your emulator)

If everything goes as planned you should see an output similar to

Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK

If you've got this output in your terminal just jump and shout hurraaaay! (watch out for the ceiling fan)

Now all is set to grok the emulator

1. Let's change the network status from 3G to Edge and back
Type
network speed edge
Observe your emulator's signal indicator changing to show edge
Now type
network speed 3g
Observe your emulator's signal indicator changing to show 3G

(Wait! Wait!!, don't jump yet)

2.Let's simulate an incoming sms
Type 
sms send 0200662782 "Howdy?, Mr Spanky emulator" (Change the phone number)
Observe your emulator's notification bar as your girlfriend drops in a new romantic message
Mind you, this isn't a replacement for WhatsApp, Lol!

3.Let's simulate a low-battery environment
Type
power capacity 4
Observe your battery indicator drop to 4%
Don't keep doing this cos you don't know when ECG will get you a real low-battery situation.

NOTE :
There are tonnes of command you should know of. Apply whatever you've learnt here to simulate such situation when needed to test your apps in the emulator.
Want to be a groking monster? Point your browser here.

May 2014 kick 2013's flat ass!!!