Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Stefan Neidig - Best practises for android deve...

Stefan Neidig - Best practises for android development as a daily business

droidcon Berlin

July 17, 2018
Tweet

More Decks by droidcon Berlin

Other Decks in Programming

Transcript

  1. Stefan Neidig, Software Architect appcom interactive GmbH 25/06/2018, Berlin Best

    practises for android development as a daily business appcom interactive
  2. Best practises for android development as a daily business -

    2/26 - Founded 2010 in Düsseldorf - Roughly 35 experts - Enterprise software, digital products - Experience of 15 years in software development - Software architect, Android developer - 3+ years at appcom appcom interactive
  3. Best practises for android development as a daily business -

    3/26 This is not… • An infomercial • A self adulation appcom interactive
  4. Best practises for android development as a daily business -

    4/26 So why should you care? • We just want to share -> So why not? • Besides we • Released many projects for enterprise clients • Implemented a lot of challenging features • Passed quality gates  appcom interactive
  5. Best practises for android development as a daily business -

    7/26 How did we start? Pro - Stable but small department - Know how of - Clean code - Important libraries - Architecture Contra - Many concurrent projects - Tight deadlines - Various requirements - API 9 - Citrix XenMobile Store - Material design - Phone/Tablet appcom interactive
  6. Best practises for android development as a daily business -

    8/26 What were the main issues? Contra - Many concurrent projects appcom interactive
  7. Best practises for android development as a daily business -

    9/26 What were the main issues? Contra - Tight deadlines appcom interactive Best practises for android development as a daily business - 9/24
  8. Best practises for android development as a daily business -

    10/26 What were the main issues? small department Contra appcom interactive Best practises for android development as a daily business - 10/24
  9. Best practises for android development as a daily business -

    11/26 So what did we do? appcom interactive
  10. Best practises for android development as a daily business -

    12/26 Use annotations where possible public class MainActivity extends AppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } appcom interactive
  11. Best practises for android development as a daily business -

    13/26 Use annotations where possible public class BaseActivity extends AppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutResID()); } private int getLayoutResID() { Annotation annotation = ((Object) this).getClass().getAnnotation(Layout.class); if (annotation == null) { throw new IllegalArgumentException("No layout resource found"); } return ((Layout) annotation).value(); } } appcom interactive
  12. Best practises for android development as a daily business -

    14/26 Use annotations where possible @Layout(R.layout.activity_main) public class MainActivity extends BaseActivity { } @Layout(R.layout.activity_dashboard) public class DashboardActivity extends BaseActivity { } @Layout(R.layout.activity_detail) public class DetailActivity extends BaseActivity { } appcom interactive
  13. Best practises for android development as a daily business -

    15/26 Use libraries where possible Timber Dagger 2 Retrofit 2 Butterknife RxJava 2 Picasso DBFlow Jsoup Exomedia Requery Materialdialog CircleImageView appcom interactive
  14. Best practises for android development as a daily business -

    16/26 Define a codestyle @Override public void foo(String bar) { //A comment String bar2 = bar.subString(0, bar.size() - 1); } @Override public void Foo2( String bar ) { // another comment … } @Override public void foo(String bar) { // A comment String bar2 = bar.subString(0, bar.size() - 1); } @Override public void foo2(String bar) { // another comment … } https://github.com/square/java-code-styles appcom interactive
  15. Best practises for android development as a daily business -

    17/26 Define code guidelines appcom interactive https://github.com/appcom-interactive/android
  16. Best practises for android development as a daily business -

    18/26 Derive live templates binv @BindView(R.id.$VIEW_ID$) $TYPE$ $VIEW_ID_CAMELCASED$; @BindView(R.id.user_preview_image_view) ImageView userPreviewImageView; timd Timber.d($END$); onclick @OnClick(R.id.$VIEW_ID$) public void on$VIEW_ID_CAPITALIZED$Clicked(View view) { $END$ } @OnClick(R.id.login_button) public void onLoginButtonClicked(View view) { $END$ } https://github.com/appcom-interactive/android-livetemplates appcom interactive
  17. Best practises for android development as a daily business -

    19/26 Apply an architecture Fragment Presenter Interactor Component Module 1 1 1 n Activity Component Module Controllers Application Component Module Controllers Application scope Activity scope Fragment scope appcom interactive
  18. Best practises for android development as a daily business -

    20/26 Apply an architecture Web datasource Localdatasource Database datasource Memory datasource Entities Models Datastore Datasource 1 n Transformer n m Interactor publicclassEntity { publicinttype; publicCompoundClassproperty; } publicclassModel { publicint type; publicint compoundClassProperty1; publicString compoundClassProperty1; … } appcom interactive
  19. Best practises for android development as a daily business -

    21/26 Override toString for POJOs 03-30 17:30:45.932 19664-19664/? D/ExampleApp ExampleAppApplication.java - onCreate:29: exampleapp.appcominteractive.com.model.entities.Person@c8b20a2 03-30 17:30:45.932 19664-19664/? D/ExampleApp ExampleAppApplication.java - onCreate:29: Person{id=42, name='Stefan Neidig', age=30, height=178.5, weight=9000.0} 03-30 17:30:45.932 19664-19664/? D/ExampleApp ExampleAppApplication.java - onCreate:29: {"id": 42, "name": "Stefan Neidig", "age": 30, "height": 178.5, "weight": 9000.0} { "id": 42, "name": "Stefan Neidig", "age": 30, "height": 178.5, "weight": 9000.0 } appcom interactive
  20. Best practises for android development as a daily business -

    22/26 Summary • Write less code and have more time • Convention over configuration • Automisation • Architecture
  21. Best practises for android development as a daily business -

    23/26 Have fun! LEARN. SHARE. HELP. appcom interactive
  22. Best practises for android development as a daily business -

    24/26 My exclusive offer for you @droidcon appcom interactive 1) VISIT US: https://info.appcom-interactive.de/droidcon 2) Join us in the next 2 days. 3) The first 10 registrations are able to win an Enterprise-workshop for <FREE> (instead 2.800,- Euro) Enterprise-Workshop: Building a disruptive App-Product - Mobile app architecture - Disruptive Mindset - UX Success - Lean Startup - My first Product
  23. Best practises for android development as a daily business -

    25/26 Reach out to us! appcom interactive www.appcom-interactive.de appcom.interactive @weareappcom appcom-interactive appcom interactive