Skip to content

πŸ–ŠοΈ π™²πš›πšŽπšŠπšπš’πš—πš π™½πš˜πšπšŽπšœ πšŠπš—πš πšŒπšŠπšŒπš‘πš’πš—πš πšπš‘πšŽ 𝚍𝚊𝚝𝚊. π™±πšžπš’πš•πš πš˜πš— π™Όπš…πš…π™Ό-πš‹πšŠπšœπšŽπš πšŒπš•πšŽπšŠπš— πšŠπš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ πš πš‘πš’πšŒπš‘ πšœπšžπš™πš™πš˜πš›πšπšœ πšŠπš•πš• π™²πšπš„π™³ πš˜πš™πšŽπš›πšŠπšπš’πš˜πš—πšœ 𝚘𝚏 πšπš‘πšŽ πšπšŠπšπšŠπš‹πšŠπšœπšŽ

License

Notifications You must be signed in to change notification settings

devrath/NoteApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

66 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

cover

π™½πš˜πšπšŽπ™°πš™πš™

πšƒπš‘πš’πšœ πš™πš›πš˜πš“πšŽπšŒπš πš’πšœ 𝚊 πšœπš’πš–πš™πš•πšŽ πš—πš˜πšπšŽ πšŠπš™πš™πš•πš’πšŒπšŠπšπš’πš˜πš—, πš†πš‘πšŽπš›πšŽ 𝚊 πšžπšœπšŽπš› πšŒπšŠπš— πšŒπš›πšŽπšŠπšπšŽ πš—πš˜πšπšŽπšœ, π™Όπš˜πšπš’πšπš’ πšπš‘πšŽ πšŽπš‘πš’πšœπšπš’πš—πš πš—πš˜πšπšŽπšœ πšŠπš—πš π™³πšŽπš•πšŽπšπšŽ πšŽπš‘πš’πšœπšπš’πš—πš πš—πš˜πšπšŽπšœ πšœπšžπš™πš™πš˜πš›πšπš’πš—πš πšŠπš•πš• πšπš‘πšŽ π™²πšπš„π™³ πš˜πš™πšŽπš›πšŠπšπš’πš˜πš—πšœ. πšƒπš‘πšŽ πš—πš˜πšπšŽπšœ πšŠπš›πšŽ πšŒπšŠπšŒπš‘πšŽπš πš˜πš— πšπš‘πšŽ πšπšŽπšŸπš’πšŒπšŽ, π™±πšžπš’πš•πš πš˜πš— πšŠπš— π™Όπš…πš…π™Ό-πš‹πšŠπšœπšŽπš πšŒπš•πšŽπšŠπš— πšŠπš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ, πšŠπš—πš πšŒπš˜πš–πš™πš˜πšœπšŽ 𝚊𝚜 πšπš‘πšŽ πš™πš›πšŽπšœπšŽπš—πšπšŠπšπš’πš˜πš— πš•πšŠπš’πšŽπš›


π™²πš•πšŽπšŠπš— πšŠπš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ 🎈

architecture

πš†πš‘πšŠπš πš’πšœ πšŒπš•πšŽπšŠπš— πšŠπš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ

  • Having one concern per component, Meaning each piece of our architecture does only one thing and nothing else. If one component is doing more than one thing, we need to split them
  • It is structured layered dependency. It is not specific to mobile development instead its software development architecture.
  • Clean architecture term comes from Uncle bob, He created this methodology for building software products.
  • It actually uses existing architectures like mvvm and other and additionally uses use-cases etc
  • It makes your applicaiton scalable majorly involves, how easy it is to replace a layer of application without breaking the other layers.
  • A large code base comes with challenge of structuring it which involves how easy it is to extend it, test the functions in it, understand it

π™°πšπšŸπšŠπš—πšπšŠπšπšŽπšœ 𝚘𝚏 πšŒπš•πšŽπšŠπš— πšŠπš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ

Advantages How its useful
Strict architecture Because of how the layers of code are organized it is not easy to make mistakes
Encapsulation Each layer is organized into its own part having its own responsibility
Parallel development If we have each feature in module wise each of the modules are built parallely
Highly scalable Once organized properly, we can grow a small project into large one without bumping to problems
Simple and easy Due to single responsibility its way easier to understand each snipped of code on what it does
Testing Since all the layers are decoupled, we can write unit tests on them easily

πš‚π™Ύπ™»π™Έπ™³ - πš™πš›πš’πš—πšŒπš’πš™πš•πšŽπšœ

πš‚πš’πš—πšπš•πšŽ πš›πšŽπšœπš™πš˜πš—πšœπš’πš‹πš’πš•πš’πšπš’ πš™πš›πš’πš—πšŒπš’πš™πš•πšŽ
  • A class should have only one job.
  • A class should have only one reason to change.
  • If the class has two reasons to change, Then the class has to be split up into two components.
π™Ύπš™πšŽπš— π™²πš•πš˜πšœπšŽπš πš™πš›πš’πš—πšŒπš’πš™πš•πšŽ
  • It should be open for extension, but closed for modification.
  • If new functionality needs to be added, it should be added as an extension of the class.
  • This allows us to abstract the stable functionality.
  • If functionality is working and stable and we add a new feature on top of the existing feature for it. Now we will have stable functionality always working.
  • Thus the volatile functionality will be in the extended classes and the stable functionality in the extended classes.
π™»πš’πšœπš”πš˜πšŸ πšœπšžπš‹πšœπšπš’πšπšžπšπš’πš˜πš— πš™πš›πš’πš—πšŒπš’πš™πš•πšŽ
  • Lower level classes can be substituted without affecting higher levels.
  • This is achieved using abstract classes and interfaces.
π™Έπš—πšπšŽπš›πšπšŠπšŒπšŽ πšœπšŽπšπš›πšŽπšπšŠπšπš’πš˜πš— πš™πš›πš’πš—πšŒπš’πš™πš•πšŽ
  • We use an interface to advertise the functionality.
  • Many specific interfaces are better than a generic interface.
  • Interface just exposes the methods the dependent classes needed and nothing else.
π™³πšŽπš™πšŽπš—πšπšŽπš—πšŒπš’ πš’πš—πšŸπšŽπš›πšœπš’πš˜πš— πš™πš›πš’πš—πšŒπš’πš™πš•πšŽ
  • Concrete classes depend on abstract classes and not the other way around.
  • Volatile and stable functionalities are encapsulated, having the dependency relationship between the two.
  • Framework-specific functionality depends on business logic with a dependency between them.

π™»πšŠπš’πšŽπš›πšœ 𝚘𝚏 πš™πš›πš˜πš“πšŽπšŒπš πšŠπš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ

architecture-layers

π™Όπš˜πš›πšŽ π™½πš˜πšπšŽπšœ

πšπšŽπš™πš˜πšœπš’πšπš˜πš›πš’:
  • Here in the project we have database, We use the database and call the functions of DAO in our repository.
  • The repository directly accesses our datasources, wither API or database.
  • The repository takes these datasources and determine which data has to be forwarded to the corrosponding use-cases.
  • Say if you have two data sources(API,Cache), The repository needs to determine, do we load the data fro API or the cache.
  • The decesion logic of determing the choosing of data source and determining if there is any errors during this.
πš„πšœπšŽπ™²πšŠπšœπšŽπšœ:
  • Use-cases shouldn't know where the repository gets the data from.
  • They just get the data and thats it.
  • Contains the business logic.
  • Makes code very redable, Because essentially the use-case is is something that does one thing.
  • We can just know what a class does by just reading the name of the class. Ex: DeleteNoteUseCase determines this is used to delete a note.
  • They make code very re-usable, because in the end the view-model call the use-cases.
  • If you implement the all the business logic in view-model and say if you need that logic in a different view model its not possible, Using a use-case overcomes this by re-using hte use-case class in a different view-model.
πšπšŽπš™πš˜πšœπš’πšπš˜πš›πš’ πšπšŽπšπš’πš—πš’πšπš’πš˜πš— πš’πš— πšπš‘πšŽ πšπš˜πš–πšŠπš’πš— πš•πšŠπš’πšŽπš›:
  • This is useful because we can create fake versions of the repository for testing
  • We can pass fake repository to use cases for testing so that use cases won't know where the data is coming from
  • Say its from a real repository or a local json file, They just get data and do something from it
πš…πš’πšŽπš -π™Όπš˜πšπšŽπš•:
  • When we just use a mvvm architecture, we have all the business logic in the view-model
  • But when we use clean-architecture in combination with mvvm, the business logic is lifted to use-case layer.
  • So the view model puts some inputs to a use-case and performs some computation based on the input and gets the result and delegates the resut as a state to the presentation(UI) layer.

π™ΏπšŠπšŒπš”πšŠπšπšŽ πš‚πšπš›πšžπšŒπšπšžπš›πšŽ πš’πš— πšπš‘πšŽ πš™πš›πš˜πš“πšŽπšŒπš πŸ“¦

Project Folder                                    
.
β”œβ”€β”€ app                                           
|   |
β”‚   β”œβ”€β”€> DI   
|   |
β”‚   |──> Feature
|   |    |
|   |    |──-------------> Data
|   |    |                  |
|   |    |                  |──-------------> DataSource
|   |    |                  |    
|   |    |                  └──-------------> Repository 
|   |    |
|   |    |──-------------> Domain
|   |    |                  |
|   |    |                  |──-------------> Model
|   |    |                  |
|   |    |                  |──-------------> RepositoryDefinition
|   |    |                  |
|   |    |                  |──-------------> UseCase
|   |    |                  |
|   |    |                  └──-------------> Util 
|   |    |
|   |    └──-------------> Presentation 
|   |                       |
|   |                       |──-------------> Screen1
|   |                       |                 |  
|   |                       |                 |
|   |                       |                 └──-------------> Components 
|   |                       |
|   |                       └──-------------------------------> MainActivity 
|   |                       
|   |──> UI
|   |    |
|   |    └──--------------------------------------------------> Theme 
|   |
β”‚   └──-------------------------------------------------------> ApplicationClass                

Modes

π™³πšŠπš›πš” π™Όπš˜πšπšŽπŸŒš

π™½πš˜πšπšŽπšœ π™»πš’πšœπš πš…πš’πšŽπš  π™½πš˜πšπšŽ π™΄πšπš’πš πš—πš˜πšπšŽ

π™»πš’πšπš‘πš π™Όπš˜πšπšŽπŸŒž

π™½πš˜πšπšŽπšœ π™»πš’πšœπš πš…πš’πšŽπš  π™½πš˜πšπšŽ π™΄πšπš’πš πš—πš˜πšπšŽ

π™³πšŽπš–πš˜ πŸ—Ό

Demo.mp4

πš‚πšžπš™πš™πš˜πš›πš β˜•

If you feel like support me a coffee for my efforts, I would greatly appreciate it.
Buy Me A Coffee

π™²πš˜πš—πšπš›πš’πš‹πšžπšπšŽ πŸ™‹β€β™‚οΈ

Read contribution guidelines for more information regarding contribution.

π™΅πšŽπšŽπšπš‹πšŠπšŒπš” ✍️

Feature requests are always welcome, File an issue here.

π™΅πš’πš—πš πšπš‘πš’πšœ πš™πš›πš˜πš“πšŽπšŒπš πšžπšœπšŽπšπšžπš• ? ❀️

Support it by clicking the ⭐ button on the upper right of this page. ✌️

π™»πš’πšŒπšŽπš—πšœπšŽ Licence πŸ’³

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

About

πŸ–ŠοΈ π™²πš›πšŽπšŠπšπš’πš—πš π™½πš˜πšπšŽπšœ πšŠπš—πš πšŒπšŠπšŒπš‘πš’πš—πš πšπš‘πšŽ 𝚍𝚊𝚝𝚊. π™±πšžπš’πš•πš πš˜πš— π™Όπš…πš…π™Ό-πš‹πšŠπšœπšŽπš πšŒπš•πšŽπšŠπš— πšŠπš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ πš πš‘πš’πšŒπš‘ πšœπšžπš™πš™πš˜πš›πšπšœ πšŠπš•πš• π™²πšπš„π™³ πš˜πš™πšŽπš›πšŠπšπš’πš˜πš—πšœ 𝚘𝚏 πšπš‘πšŽ πšπšŠπšπšŠπš‹πšŠπšœπšŽ

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages