code quality

7
Code Quality (Generic) Hussain Mansoor Systems Ltd.

Upload: husyn-raj

Post on 13-Jun-2015

54 views

Category:

Software


1 download

DESCRIPTION

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.

TRANSCRIPT

Page 1: Code quality

Code Quality (Generic)Hussain Mansoor Systems Ltd.

Page 2: Code quality

Light ViewControllers/Activities

Remove database fetching methods (or insertions)

It should be via DB Layer

Remove Network requestsIt should be via Network Layer

JSON/XML Parsing is also not a part of Controllers/Activity

Move Common code into BaseClass

Page 3: Code quality

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

Page 4: Code quality

Overriding useful methods

toString() / [object description]

Comparator methods

Page 5: Code quality

Values in codeAll 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

Page 6: Code quality

Code improvementsUse ‘lint’ tool in Android

Use Analyze feature of Xcode

Profile for Memory

Profile for Processing

Page 7: Code quality

DebuggingUse 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