Slide 1

Slide 1 text

Clean Architecture स्वच्छ सॉफ्टवेयर अिभयान ✨

Slide 2

Slide 2 text

Find the difference

Slide 3

Slide 3 text

Both orders are the same!

Slide 4

Slide 4 text

Shared Vocabulary • Not only does it makes it easier to communicate with the cook, but it gives the cook less to remember because he’s got all the diner patterns in his head. • Once you’ve got the vocabulary you can more easily communicate with other developers and inspire those who don’t know patterns to start learning them. • It also elevates your thinking about architectures by letting you think at the pattern level, not the nitty-gritty object level.

Slide 5

Slide 5 text

Your architecture should scream the purpose of the app. - Robert C. Martin (Uncle Bob) More technically said, business logic should be clearly separated and independent of the framework.

Slide 6

Slide 6 text

4 golden rules of Architecture 1. Satisfy a multitude of stakeholders. 2. Encourage separation of concerns. 3. Run away from the real world (Android, DB, Internet etc). 4. Enable your components to be testable.

Slide 7

Slide 7 text

Outer layers: Mechanisms Inner layers: Policies Dependency rule: Source code dependencies can only point inwards. A layer can communicate only one layer below.

Slide 8

Slide 8 text

① Entities • Enterprise (Uber) wide business rules. • Can be object with methods or set of data structures and functions. • Encapsulate most general and high level rules. • Least likely to change when something external changes (like page navigation, security etc). • For News app like NYT, entities would be Category, Article, Commercial etc.

Slide 9

Slide 9 text

② Use Cases • Contains Application specific business rules. • Encapsulates all use cases of the system. • Orchestrate data flow to and from entities. • Doesn’t change with entities or externalities (UI, DB etc). • However, changes to operation of application will affect the use cases. • Ex. Transfer money from one account to another will be “TransferMoneyUseCase”.

Slide 10

Slide 10 text

③ Interface Adapters • Set of adapters that convert data from format convenient to use cases/entities to a format convenient to an external agency (UI, DB, Web etc). • Contains MVC architecture of a GUI (Presenters, Views, Controllers etc). • Models are just data structures that are passed from controllers to use cases and then back from use cases to presenters and views.

Slide 11

Slide 11 text

④ Frameworks and Drivers • Tools like Database, Web Framework etc. • We only write the glue code here which binds the inner circles. • Details go here (UI, DB, Web etc). These are kept outside where they can do little harm.

Slide 12

Slide 12 text

As you go inwards, software grows more abstract and encapsulates higher level policies.

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Crossing boundaries Dependency rule: Source code dependencies can only point inwards. Dependency Inversion Principle: We would arrange interfaces and inheritance relationships such that the source code dependencies oppose the flow of control at just the right points across the boundary.

Slide 15

Slide 15 text

Clean Architecture in Android

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Five Clean Arch Satisfies 4 golden rules of Architecture

Slide 18

Slide 18 text

1st rule of Architecture

Slide 19

Slide 19 text

2nd rule of Architecture

Slide 20

Slide 20 text

3rd rule of Architecture

Slide 21

Slide 21 text

4th rule of Architecture

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Buffer Clean Arch

Slide 24

Slide 24 text

References • https://blog.cleancoder.com/uncle-bob/2012/08/13/the- clean-architecture.html • https://github.com/bufferapp/android-clean-architecture- boilerplate • https://five.agency/android-architecture-part-4-applying- clean-architecture-on-android-hands-on/ • https://fernandocejas.com/2015/07/18/architecting- android-the-evolution/

Slide 25

Slide 25 text

fin Thank you! Chetan Sachdeva, Uber