Fighting against Android for the Right to Use Composition
Поговорим о том, что не так с MVP и его старшим братом MVC. И разберем как обойти ошибки проектирования Android и писать (хотя бы немного) повторно используемый объектно-ориентированный код.
— cannot be decorated or substituted; • Not segregated; • Implementation dependency; • Does not represent a solid object, its behaviour and state. Is just a bunch of procedures.
• View-Presenter abstraction has leaked; • View and Presenter are separated by means of interfaces but without any code reuse and polymorphism; • Presenter is a bunch of procedures, like a Controller
• View-Presenter abstraction has leaked; • View and Presenter are separated by means of interfaces but without any code reuse and polymorphism; • Presenter is a bunch of procedures, like a Controller; • View and Presenter hold links to each other which is very strange and discouraged practice
• View-Presenter abstraction has leaked; • View and Presenter are separated by means of interfaces but without any code reuse and polymorphism; • Presenter is a bunch of procedures, like a Controller; • View and Presenter hold links to each other which is very strange and discouraged practice; • Presenter is logically tied to Android platform.
• Fragments forbid composition; • One Fragment + Presenter per use case — no code reuse! • Fragment resolves its own dependencies, like singleton; • Passing an argument deeply through flow based on Fragment stack is painful and unmaintainable.
different implementations of the same interfaces? • This is a dead end: we’ll get scopes and qualifiers, configs which can break something somewhere, dependencies on implementations instead of abstractions
different implementations of the same interfaces? • This is a dead end: we’ll get scopes and qualifiers, configs which can break something somewhere, dependencies on implementations instead of abstractions; • This introduces semantics of dynamic weakly-typed languages.
screens by means of object or functional composition Search books Effective Java, 3rd Edition by Joshua Bloch Java Generics FAQ by Angelika Langer Java Performance: The... by Scott Oaks Thinking in Java, 4th edit... by Bruce Eckel Kotlin in Action by D. Jemerov and S. Isakova Search books Effective Java, 3rd Edition by Joshua Bloch Java Generics FAQ by Angelika Langer Java Performance: The... by Scott Oaks Thinking in Java, 4th edit... by Bruce Eckel Kotlin in Action by D. Jemerov and S. Isakova Paradigms Books Websites Procedural Simple and Annoying Functional Fascinating and Crazy Train Procedural Old and digesting Object-Oriented Interfaces and Composition Procedural You can write it even in Java Amazon.com Expensive books GitHub.com My favourite social net Twitter.com Read programmers’ jokes StackOverflow.com Downvote stupid questions Javanese.online WTF is this? Search paradigms Search websites
screens by means of object or functional composition; • Escape onActivityResult and onRequestPermissionResult hell; • Allow hierarchical communication (parent-child)
screens by means of object or functional composition; • Escape onActivityResult and onRequestPermissionResult hell; • Allow hierarchical communication (parent-child); • Transparent work with userVisibleHint
screens by means of object or functional composition; • Escape onActivityResult and onRequestPermissionResult hell; • Allow hierarchical communication (parent-child); • Transparent work with userVisibleHint; • SOLID, reusable, cross-platform Presenters.
an object we are objects https://github.com/JavaneseOnline/KRUD/blob/master/krud-core/src/main/kotlin/online/javanese/krud/crud/Crud.kt Refactored Controller
Parcelable. OK for data and functional objects, not for Observables, DB or net connections; • Ugly constructors; • Using Bundles • possible typos in keys
Parcelable. OK for data and functional objects, not for Observables, DB or net connections; • Ugly constructors; • Using Bundles • possible typos in keys; • possible heap pollution in getParcelable<T>
Parcelable. OK for data and functional objects, not for Observables, DB or net connections; • Ugly constructors; • Using Bundles • possible typos in keys; • possible heap pollution in getParcelable<T>; • custom Map and List storage surprises.