How to Train your `droid`?

Hello droid!

If you are looking for a technical training kind of an article, you have come to the wrong place then :). I am writing this to share a few “things” about Android that I have experienced / heard, so that we can all have some fun time while our gradle builds are running or while we are sipping a cup of tea or maybe in the middle of a boring meeting.

WARNING!

Kindly read at your own risk. Don’t miss the Damage-control links!

Let’s begin! Shall we?

Afor Activity. Activity in android is one of the main components. Almost every application contains at least one Activity.

“Best way to prevent your Activity from getting restarted on orientation change is to set android`:configChanges` and just forgetting about it.”

Bfor Broadcast. Android is a chatty place, it’s components like to talk to one another and they can do so via broadcasts.

“Broadcast Receiver’s onReceive() is your stage. Go wild here and perform all the long running tasks.”

Cfor ContentProvider. ContentProvider provides us with an abstract layer and a way to share data among different applications.

“Creating a ContentProvider for your application is a MUSTfor you. You don’t seem to have a life anyway.”

Dfor Doze Mode. Android Devices can explode if they don’t doze off for a while. Android also takes a nap when you don’t play with it.

No-body cares about your Alarms, your Wake-locks, your sync jobs or even your app. Why should you?”

Efor Elevation. It is to show that a certain sheet of paper lies above the other paper. For instance, FABs lie above your screen and are elevated.

“Best way to have elevation in your apps is to just use setElevation() function and a get a super-ugly flat UI on pre-lollipop devices. Deal With It!”

Ffor Firebase. Firebase provides us with tools to create great apps. In 2016, the company was acquired by Google and that’s why I/O 2016 was filled by almost all Firebase stuff.

“Start by Realtime Database to cache all your data. Upgrade to FCM or your phone might not wake up once it dozes off. Firebase all the things!”

Gfor Gradle. Used to automate and manage the build process and produce your apk and aar‘s for you. Intention is to make your build process smooth.

“I love Gradle! It makes our life full of power-naps and TT.”

Hfor Handler. Handler is tied to a thread and is used to handle messages. It can be instantiated using the main Looper instance Looper.getMainLooper(). It is usually used to execute certain tasks on UI thread via messages coming from a background thread.

Animation not running? Keyboard not showing up? width/ height is 0? Do the magical handler.postDelayed() and you are good! Yeah go ahead and pat your back.

Well Done Source

Ifor Intent. Intent is the intention to perform a certain action. It can be Explicit (Direct — Authoritatively announce to perform an action like an extrovert) or Implicit (Indirect — First give a signal regarding your intention and perform an action when invited like an introvert).

“Feeling too Lazy to implement a feature? Throw an Intent and just let other apps handle it!”

Jfor Java. It’s an awesome programming language which is meant to WORA — Write Once, Run Anywhere . Java was developed by James Gosling of Sun Microsystems (acquired by Oracle). Android applications can be written using Java.

“Damn! WORA — Write Once Regret Always”

Kfor Kotlin. Kotlin is a statically typed, JVM based programming language. It is highly interoperable with JAVA and is a very attractive alternate to Java Developers who are sick of it’s verbosity (not me, I have an IDE).

“I once wrote an Application in Kotlin. Code | Convert Java File to Kotlin File.”

I would have definitely given it a try if it was named Korean though.

L-> {Lambda Expressions}. Less formal and more readable expressions.

“I like verbose.”

Mfor MVP. It stands for Model-View-Presenter. It is an architectural pattern to separate the logic from the presentation layer. More and more people are adopting this pattern for Android Development these days.

“Let’s make our lives a living hell and drown in the ocean of unlimited classes and interfaces.”

Source

Ofor OkJesse. Jesse Wilson, developer at Square told in one of the Fragmented Podcasts about the reason behind naming the libraries as OkHttp, OkIO. It’s because OK is a moment to rejoice for all of us :

“We, Developers live to get a 200 OK from the API. Always”

Pfor PendingIntent. It is an Intent that you give to another application to run. Pending Intent runs with our permissions in somebody else’s environment. Example: Alarms.

“Lazy to complete a task? Pass it to another application as a pending intent instead.”

Qfor Query. Your app has a database. You want to fetch some records. Guess what you need for that? No! you need to have some data in the database first and then you can query!

Select * from PJs WHERE name like ‘Q%’ ;

0 results found.

Rfor Rxify. Rxify is the term given by me to the use of Reactive programming and it’s operators. I believe that reactive programming can achieve difficult and error-prone tasks easily at the flick of a wrist.

“I love MAGIC! But with great POWER comes MissingBackpressureException”

Sfor Service. Service is one of the main components of Android. They do not have a UI of their own and are supposed to perform some tasks which do not involve much user interaction.

“Service runs in background, Go Ahead and do all your ugly stuff here and die in the hands of ANR.”

Tfor TDD. TDD stands for Test Driven Development. It’s the practice which says that we should first write all the test cases for anything we develop which all initially fail. We should then code to make them all pass.

“Let’s aim for 100% test coverage and make the client pay for it.”

Ufor URI. URI stands for Uniform Resource Identifier. It is like an address which points to some “thing” of significance.

“Even after ~ 4 years of Android Development I do not fully understand the concept of URI myself. You can safely skip this section.”

Vfor View. Basic component of any User Interface in Android. On the screen it takes up a rectangular area.

“Custom Views are so cool, let’s always draw our views ourselves.”

Wfor Wharton, Jake Wharton. He is the GeekGod of Android who works at Square. He has given us “things” like ButterKnife, Dagger, Retrofit, Timber, Hugo etc.

Applications respond to Chuck Wharton even in the case of ANR.”

Xfor xml. Extensible Markup Language is designed to be both machine and human (haha.. ya right!) readable. Using xml we can define a set of rules.

“Let’s use the cool new ConstraintLayout. It can be created using the Layout Editor, no need to work with stupid xmls anymore. … 4 hours later…. *creates a LinearLayout using xml*.”

Yfor Yoda, you are. After you have mastered at least the things mentioned above, you can safely call yourself a pro.

“After this rigorous training you have become the Master of Android Things.”

Master of Things Source

Zfor zzz. All work and no “Zzz” makes droid a dull “thing”.

“While you were reading this article, your device probably dozed off and your dear app won’t be able to do any damn thing about it!”

TL;DR

You missed all the good stuff. No issues, go back to stare at your “Gradle Build Running” dialog then 😛

This post was partially inspired by @anddev_badvice on Twitter and title from “How to Train your Dragon” movie which is pretty awesome!

I am myself a droid who is still learning. If you think I made a mistake anywhere, or you seek an explanation to the silly stuff in this post, leave a response. Click the heart if you want your fellow droids to chill a little too.

Credits:-https://medium.com/@ragdroid
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s