1 Principles - G00fY2/android-mvp-wiki GitHub Wiki

1 Principles

Many parts of Android and the Android SDK were not written with great adaptability and flexibility in mind. To achieve manageable, testable and thus easily maintainable code we first need to look at some of the most important design principles in the world of Object Oriented Programming.

1.1 SOLID

Initial Principle
S (SRP) Single responsibility: Classes should only have single responsibility / one job
O (OCP) Open/closed: Software entities should be open for extension, closed for modification (e.g. inheritance)
L (LSP) Liskov substitution: Objects should be replaceable with instances of their subtypes without altering the correctness of the program
I (ISP) Interface segregation: specific interfaces for clients instead implementing general-purpose interface
D (DIP) Dependency inversion: higher level modules should not depend on lower ones, both should depend on abstraction / abstraction should not depend on details

1.2 Basic ideas

Object-oriented programming languages allow developers to design software providing separation of concerns. The MVP pattern is based on this idea. Just like the MVP pattern, people in the Android community quickly began to port existing software models to the Android world. The Otto library from Square was a first approach to decouple components and dependencies inside of Android applications by implementing the event bus pattern known from Java Swing applications. It was the predecessor of RxJava/RxAndroid.