Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Comments]: Can we have some accurate comments for each file of source code to help understanding? #1641

Open
polarove opened this issue Sep 27, 2024 · 1 comment

Comments

@polarove
Copy link

polarove commented Sep 27, 2024

For those beginners to this project:

This project is growing larger as days gone, and we have people from different cultures contributing on it, leading me to a situation where naming conventions / complex project structure / giant project dependencies are not efficient for understanding.

Let's first talk about the naming conventions

  1. The NiaApplication, the Nia, is that a cat meow?

  2. Names begin with Offline ( OfflineFirstTopicsRepository ) indicate LocalDevice:

    Such classess will fetch some data from the internet in some cases, it's not consist with its name Offline****.

    It should only execute functions from xxxDao to perform local data ( which might be outdated in user's device ) operation accroding to its name, ideally.

    otherwise just don't name it as Offline***, because it uses network indeed.

  3. Names end with Repository are pretty straight forward, might be holding datasource from both local device and network requests

  4. Names like Network****Resource**** ( NetworkNewsResourceExpanded ) indicate used to receive data from network requests, why don't we name it like NewsVo, Vo means View Object, and ViewModel classes (NewsViewModel) can have multiple Vos:

 class NewsViewModel : ViewModel() {
         val NewsList: List<NewsVo> = emptyList()
         val OutdatedNewsList: List<NewsVo> = emptyList()
 }
 
 data class NewsVo (
          val title: String,
          val content: String
 )
  1. Names end with DataSource indicate a class that has some method sused to fetch data from the internet

  2. Names end with Dao indicate a class that has some SQL annotated methods used to operate data in sqlite (might be outdated) on local device.

  3. And more.....

The complex project structure is really refusing me to understand a data flow

It's seperated into different modules inside different files, with interfaces hiding thier actual multiple implementations behind. I often lost in ctrl + right click in android studio's reference prompt, hard to say that this is a better parttern to be maintained.

Giant project dependencies

There are to many dependencies that need you to review

@lihenggui
Copy link
Contributor

lihenggui commented Sep 28, 2024

The NiaApplication, the Nia, is that a cat meow?

Nia represents for NowInAndroid

Names begin with Offline ( OfflineFirstTopicsRepository ) indicate LocalDevice:

It is not just Offline; it is actually OfflineFirst.You can refer the Android documentation for more information on this concept: https://developer.android.com/topic/architecture/data-layer/offline-first.

why don't we name it like NewsVo, Vo means View Object, and ViewModel classes (NewsViewModel) can have multiple Vos

You can use your preferred naming conventions in your project. People have varying preferences for conventions. I believe most people may not understand what VO stands for and might ask the same question you did.

The complex project structure is really refusing me to understand a data flow

Please read these two documents, it will help you understand why modularization is important and NIA is a showcase for this concept.
https://github.com/android/nowinandroid/blob/main/docs/ArchitectureLearningJourney.md
https://github.com/android/nowinandroid/blob/main/docs/ModularizationLearningJourney.md

You can view https://github.com/android/compose-samples for simpler samples.

Giant project dependencies

You can check out the quickstart guide provided by Google: https://developer.android.com/develop/ui/compose/setup. It's a great starting point for beginners.

Now in Android is a fully functional Android app built entirely with Kotlin and Jetpack Compose. It follows Android design and development best practices and is intended to be a useful reference for developers. As a running app, it's intended to help developers keep up-to-date with the world of Android development by providing regular news updates.

IMO it should be moved to discussion. It is not an issue though.

More discussions about architecture:
#1225
#574
#619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants