Monthly Archives: October 2012

Android Define Fields in Standard Places

Fields should be defined either at the top of the file, or immediately before the methods that use them. Source: http://source.android.com/source/code-style.html

Posted in Android, Tips and Tricks Tagged with: ,

Android Method Length

To the extent that it is feasible, methods should be kept small and focused. It is, however, recognized that long methods are sometimes appropriate, so no hard limit is placed on method length. If a method exceeds 40 lines or

Posted in Android, Tips and Tricks Tagged with: , ,

Android Use Javadoc Standard Comments

Every file should have a copyright statement at the top. Then a package statement and import statements should follow, each block separated by a blank line. And then there is the class or interface declaration. In the Javadoc comments, describe

Posted in Android, Tips and Tricks Tagged with: , ,

Android Fully Qualify Imports

When you want to use class Bar from package foo,there are two possible ways to import it: import foo.*; Pros: Potentially reduces the number of import statements. import foo.Bar; Pros: Makes it obvious what classes are actually used. Makes code

Posted in Android, Tips and Tricks Tagged with: ,

Android Don’t Use Finalizers

Finalizers are a way to have a chunk of code executed when an object is garbage collected. Pros: can be handy for doing cleanup, particularly of external resources. Cons: there are no guarantees as to when a finalizer will be

Posted in Android, Tips and Tricks Tagged with: ,

Android Don’t Catch Generic Exception

Sometimes it is tempting to be lazy when catching exceptions and do something like this: try { someComplicatedIOFunction(); // may throw IOException someComplicatedParsingFunction(); // may throw ParsingException someComplicatedSecurityFunction(); // may throw SecurityException // phew, made it all the way }

Posted in Android, Tips and Tricks Tagged with: ,

Android Don’t Ignore Exceptions

Sometimes it is tempting to write code that completely ignores an exception like this: void setServerPort(String value) { try { serverPort = Integer.parseInt(value); } catch (NumberFormatException e) { } } You must never do this. While you may think that

Posted in Android, Tips and Tricks Tagged with: ,

Android Code Style Guidelines for Contributors

The rules below are not guidelines or recommendations, but strict rules. Contributions to Android generally will not be accepted if they do not adhere to these rules. Not all existing code follows these rules, but all new code is expected to. Don’t

Posted in Android, Tips and Tricks Tagged with: ,

Android Action Bar Style Generator

Quote: “The Android Action Bar Style Generator allows you to easily create a simple, attractive and seamless custom action bar style for your Android application. It will generate all necessary nine patch assets plus associated XML drawables and styles which

Posted in Android, Tips and Tricks Tagged with: , ,

Xcode Could Not Launch App No Such File Or Directory Error

Developing in Xcode can give a lot of different errors. Here’s yet another one: Could not launch app – No such file or directory. Then a path to Users/App/Library/Developer/Xcode/DerivedData/etc… Running into this problem on multiple occasions there have been two solutions

Posted in Mac Tagged with: ,