Skip to content

Wyrther code review1#25

Open
wrytherUC wants to merge 8 commits intomasterfrom
wyrtherCodeReview1
Open

Wyrther code review1#25
wrytherUC wants to merge 8 commits intomasterfrom
wyrtherCodeReview1

Conversation

@wrytherUC
Copy link
Copy Markdown
Collaborator

@wrytherUC wrytherUC commented Mar 6, 2023

Analysis of the program.

  • This application is to help with keeping track of what kind of medication is taken and when to take it. It will also integrate with Android in the future to set up reminders.

  • Data will be stored and organized using Room, a local database. The database will be called Medicine. The Medicine DTO will define the medicine table. The Medicine DAO will define how data will be read, updated, and deleted. The MedicineRoomDatabase will bootstrap the Room database and connect the DAO and DTO. The last class, MedicineRepository, I am not sure about. One take away from it, it uses a coroutine to execute any actions against the database on a non-UI thread.

Was the program available in UC Github on time?

  • Yes

Is the program documented/commented well enough for you to understand?

  • Somewhat. There are kdocs written and the repo's README.md is a little out of date.

Does the program compile?

  • No. I resolved a few issues, but was unable to fix enough of the issues for the application to compile.

Rationale behind your changes.

  • I think my bigger changes were adding a version variable for room dependencies to make it easier to update room version. It will also make it so that they all use the same version. Could help with avoiding human error in the future.
  • I think adding non-null columns to the Medicine data entity is important from a database perspective. We do not want any entries with missing data for the medicine name, medication start day, and the length of time that it needs taken.
  • The room implementation seemed solid. Following Module 13 videos for room, there was a proper DAO, DTO, and RoomDatabase class for the Medicine data.
  • I think some important next steps to work on is how data is being added to the database. Will this be a database asset file with pre-populated data or will retrofit be used to pull JSON data to a DAO/DTO?
  • A note about git commits, I think the commit messages should have more detailed headlines, more frequent, and have smaller changes between the commits.

Links to three specific commits that you made to your own group's GitHub repository before the end of sprint deadline.

Next, list three specific technical concepts that you learned from this code review. Copy and paste samples to demonstrate your point.

Room - I watched Module 13 videos on Room, so I learned how room is boot strapped, how DTOs are used as Room data entities/table definitions, and how DAOs are used to run any CRUD operations against the database.

Room/Flow - Flow seems to be comparable to observables. If any changes are made against the database, flow will see them happen and be used to help make live updates to the UI.

@Suppress("RedundantSuspendModifier")/@workerthread - This was implemented in the application to help move any database queries or operations off of the UI thread. Seems similar to coroutines.

Copy link
Copy Markdown
Collaborator Author

@wrytherUC wrytherUC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mistakenly created this comment on the conversation thread rather than on a commit.

interface MedicineDAO {
@Query("SELECT * FROM Medicine ORDER BY name ASC")
fun getAlphabetizedMedicine(): Flow<List<Medicine>>
fun getAllAlphabetizedMedicine(): Flow<List<Medicine>>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added All to the name of the function, as the query is fetching all rows from the Medicine DB

Comment thread app/build.gradle
kapt "androidx.room:room-compiler:2.5.0"
implementation "androidx.room:room-ktx:2.5.0"
def room_version = "2.5.0"
implementation "androidx.room:room-runtime:$room_version"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added version variable to make it a little easier to update any room dependencies.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Dependencies are like whack a mole in Android.

@ColumnInfo(name = "prescription length") val lengthInDays: Int
@NonNull @ColumnInfo(name = "start date") val startDate: String,
@NonNull @ColumnInfo(name = "prescription length") val lengthInDays: Int
//,@ColumnInfo() val endDate: Date = startDate
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added non nulls, as the name of the medication, start date, and start day should be required values.

/**
* Declares the DAO as private property in the constructor.
* Pass in the DAO instead of the whole database, because you only need access to the DAO
*/
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added kdoc above the class

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.

abstract fun medicineDao(): MedicineDAO

//Singleton prevents multiple instances of database opening at the same time.
companion object {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved comment out of the actual code block and added a blank kdoc section for future documentation. Since it is a public class, there should be some documentation for it.
https://kotlinlang.org/docs/coding-conventions.html#coding-conventions-for-libraries

Comment on lines +10 to +12
/**
*
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty KDoc does not add value.

@discospiff
Copy link
Copy Markdown

A few things I'd harvest from this review.

I am cautious about empty KDoc. That is not adding any value, and is just clutter.

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

Successfully merging this pull request may close these issues.

2 participants