Highlights how to write quality code and what are some major pitfalls which we do on daily basis. Presented by me to the Mobile team at Systems Ltd on 10 October 2014.
2. Light ViewControllers/Activities
Remove database fetching methods (or
insertions)
It should be via DB Layer
Remove Network requests
It should be via Network Layer
JSON/XML Parsing is also not a part of
Controllers/Activity
Move Common code into BaseClass
3. Weak References
Have weak references of Context/Activity/View
whenever possible
By default all references are ‘STRONG’
If weak reference is Null don’t continue
WeakReference r = new WeakReference(Obj);
__block __weak
5. Values in code
All the numbers and strings should be part of
constants file
In perfect scenario code will not have any
number or string, all will be referenced via
constants
Use dimen files
Move static data into xml/plist files
6. Code improvements
Use ‘lint’ tool in Android
Use Analyze feature of Xcode
Profile for Memory
Profile for Processing
7. Debugging
Use Android provided Log class method with
sense
Every log can’t be Log.d() or Log.e()
Use Xcode Colors
Understanding debugging with threads
Disable logs for release mode