Initiation-level speech for novice / intermediate developers who want to improve their Android Development process and follow some widely extended and recommended principles.
just one thing. A class or module should have one, and only one, reason to change. “No side effects” - my class must not be affected by changes in another classes “First rule of functions: They should be small Second rule: They should be smaller than that” SOLID
App is modeled as an interaction between two main actors: the View and the Presenter. Activities / Fragments / CustomViews implement the abstract View class (do not confuse with android.view.View) Presenter represents the events that can happen to the App (onItemClicks, onDataReceived, onCreate). View represents the reactions to these events (showLoading, hideLoading, showUsersList, showErrorMessage, showPushDialog).
App is modeled as an interaction between two main actors: the View and the Presenter. Activities / Fragments / CustomViews implement the abstract View class (do not confuse with android.view.View) Presenter represents the events that can happen to the App (onItemClicks, onDataReceived, onCreate). View represents the reactions to these events (showLoading, hideLoading, showUsersList, showErrorMessage, showPushDialog).
compilation time • Helps detecting code smells (if your activity/fragment/view doesn’t fit in the naming conventions, you’re probably doing it wrong) • Avoids NPEs and other errors due to name clashes (R.id.title) Examples can be found on the next slides...
Three main ways of implementing CustomViews (there are more) Very likely to do Open/Closed code! 1. Extending from Widgets (TextView, ImageView, EditText…) 2. Extending from Layout / ViewGroup, then inflating XML layout 3. Extending from View and overriding onDraw to paint on canvas
into different .xml files instead of one styles.xml ◦ res/values/button_styles.xml ◦ res/values/textview_styles.xml ◦ res/values/mycustomview_styles.xml • Also separate your styleables into different files (one file per CustomView) Styles
could be an example ▪ datasource ▹ api ◦ parse ◦ retrofit ▹ mock ▹ db ◦ model ▪ global ▹ di ▹ util ▹ model ▹ MyApplication.java Package distribution ▪ interactor ▹ impl ▪ ui ▹ activity ▹ fragment ▹ view ▹ presenter
◦ Move line up / down ◦ Duplicate line ◦ Alt+Enter > Implement abstract class ◦ Alt+Enter > Create field / local var / method ◦ Alt+Enter > declare public / protected ◦ and much much more... • Live templates (use them with responsibility!) Android Studio Features