Read complete story

Android Development – The Good Parts

There are a lot of tricks and shortcut that “lazy” developer(s) uses in their daily routine. Here is a list of few tips and tricks that might be helpful during android programming.

1. Adding “TAG”

Adding tag always helpful. It is a good practice to add one TAG to identify any .java file. The main use is for logging and debugging. It is efficient to have one TAG for each .java file instead of having random tags or a Global tag.  You might not be logging in some file like model classes but still, you should add TAG in it.

There are already predefined shortcuts like logt, logd in the android studio to make this work easy for you.

2. Never leave a catch block empty

Exceptions are always thrown even if you code with utmost validation. So it better to let the user aware of the problem or handle the situation efficiently rather than leaving the empty catch block or printing the stack trace.

3. Write long code/functionality/feature at once instead of short updates

It is better to write all the existing cases, designing the complete view, applying attributes and like that at once rather than writing code line by line or adding an attribute on a view to check the effect. This is seriously a non-efficient approach of doing a thing. Plus, this will eventually increase the productivity and you will never cry for the slow build time for your setup.

4. Better comment the code instead of removing it for the sake of clean code or project.

For clean code, you must follow the standard programming guidelines, design patterns, and clean project architecture. Remove code only when you are assured that you will not need it.

5. Beware of NPE

You must never take NPE with ease, otherwise, you will end it an ANR (Android not responding).

You can use various tricks like:

6. Use ToDo(s)

As Human make mistakes and always miss something.

 

 

7. Use Refractor

There is no need to use refractor “judiciously”. Just review what changes are going to refractor and you are good to go.  Use arrows to navigate and view changes just like we do in the todo(s).

 

 

8. Focus on one task without migrating to another

to achieve this you can prepare the todo(s) in your application project. You can prepare bookmark that you want to continue with. Instead partially completing it and moving to one another. I am sure one can be more focused and productive using this approach.

 

9. Use debugger

Apart from debugging using a debugger, we can use it for multiple purposes. E.g. checking the content of data etc.  It is not necessary to override toString() method of a model we can use the debugger to check its key and value e.g. RemoteMessage class of Firebase messaging there is no overridden toString() method and thus it is little tricky to log all the data arriving when onMessageReceived(RemoteMessage remoteMessage) is called. It’s better to add a breakpoint and check the content of the remoteMessage would be handy.

 

10. Make Base Class for most of the things.

It will be helpful to handle and perform common task. Especially where lifecycle is related like BaseActivity, Base Fragment etc.

 

 

 

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close