3. SOLID Design Pattern
! Reduces tight coupling between classes.
! Loose coupled classes minimise change in code.
! Helps in making code more reusable, maintainable,
flexible, stable and suitable to work in a team.
! SOLID represents 5 design principles.
4. SOLID- 5 Design Principles
! S - Single Reasonability Principle
! O - Open - Closed Principle
! L - Liskov Substitution Principle
! I - Interface Segregation Principle
! D - Dependency Inversion Principle
5. Single Reasonability Principle (SRP)
It says that there should be not more than one reason for a class
to change and has only one responsibility.
6. Open - Closed Principle (OCP)
• Open - Software entities should be open for extension.
• Closed - Closed for modification.
7.
8. Liskov Substitution Principle (LSP)
It states that Derived or child classes must be substitutable for
their base or parent classes.
9. Interface Segregation Principle (ISP)
• It state that do not force any client to implement an interface
which is irrelevant to them.
• Avoid Interface Pollution.
10. Dependency Inversion Principle (DIP)
• Talks about Coupling between two modules.
• High-Level Modules shouldn’t depend on low level modules.
Both should depend on abstraction.
• It focuses on the approach where the higher classes are not
dependent on the lower classes instead depend upon the
abstraction of the lower classes.
11.
12. Architecture Pattern
! Software Architecture pattern promotes organised
programming.
! Separates application functionality which is easy to test
and provide low cost maintenance.
! MVC, MVP, MVVM are some popular design pattern.
13. MVC (Model View Controller)
Controller
(Activity/Fragment)
View
(Rendering UI)
Model
(Data State + Business
Logic)
Trigger request
Process
the
request
Update
response
N
otifies
Sometimes interact with View
14. Advantage
! It keep business logic separate in the model.
! Support asynchronous techniques
! Modification does not affect the entire model
! Faster development process
Problem
! Due to large code controller is unmanageable.
! Hinders the Unit testing
! Increased Complexity
15. MVP (Model View Presenter)
Presenter
(Intermediate)
View
(XML/Activity/Fragment)
Model
(Data State + Business
Logic)
Inform
user action
Process
the
request
Update
response
Save
&
N
otifies
16. Advantage
! Code is more readable and maintainable
! Easy testing as business logic separated from UI
! Reusable of View and Presenter
Problem
! Tight coupling between View and Presenter
! Huge amount of interfaces for interaction between layers.
! Code size is quite excessive.
18. Advantage
! No tight coupling between view and view model
! No interfaces between view and model.
! Easy to unit testing and code is event driven.
Problem
! You have to create observables for each UI component.