Skip to content

Wryther code review2#32

Open
wrytherUC wants to merge 5 commits intomasterfrom
wrytherCodeReview2
Open

Wryther code review2#32
wrytherUC wants to merge 5 commits intomasterfrom
wrytherCodeReview2

Conversation

@wrytherUC
Copy link
Copy Markdown
Collaborator

@wrytherUC wrytherUC commented Apr 1, 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.

  • Updates from second review:

    • Data will be stored and organized using Firebase, a cloud database. There will be one database used, but it will have separate collections for Medicine, MedicineLogs, and user Medicine.
    • There are service classes that will interact with the Medcine and MedicineLogs collections.
    • The user medicine objects will be separated by each user.
    • Firebase will also be used for authentication.
    • The main view model works with the service IMedicineService, listens for user medicine collection changes, and for user authentication.
    • The UI does not look to be complete yet, but users can add different medications with different schedules and attributes. Some more work needs done to include medication schedules and logging.

Was the program available in UC Github on time?

  • Yes

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

  • Documentation was written, but I had a tough time understanding what the MedicineRepository class does.

Does the program compile?

  • No. I was able to resolve a few errors, but was not able to get the application to compile.

Rationale behind your changes.

  • Some of my changes were to help resolve errors that were causing the application not to run. Although I was unable to fix them all, I think this would help save the group a little bit of time.
  • Updated the UI layout XML to improve readability and consistency. Users might get confused between medicine and medication buttons. Updating all of the terms to one, consistent word should help improve the UI.
  • Making the mutable type private could help with debugging any issues with in easier in the future.
  • An update on git commits. I think the git commit messages were better for this Sprint!

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.

Layout XML files - Writing a UI from XML files (https://developer.android.com/develop/ui/views/layout/declaring-layout)

Mutable types - Best practice to keep these private to one class to improve debugging. (https://developer.android.com/kotlin/coroutines/coroutines-best-practices#mutable-types)

It might not be something quite new, but was interesting to see that this group also used Firebase DB to create separate databases/collections to keep medicine stored in.

internal val NEW_MEDICATION = "New Medication"
var medicine : MutableLiveData<List<Medicine>> = MutableLiveData<List<Medicine>>()
var selectedMedicine by mutableStateOf(Medicine())
private var selectedMedicine by mutableStateOf(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.

Making the mutableStateOf variable private makes sure changes to it are in one class only.

(https://developer.android.com/kotlin/coroutines/coroutines-best-practices)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A mutableState object will likely be accessed by an Activity class, as that's the nature of having a mutableState in the first place. private will hide this access. I urge caution when changing an access modifier in a ViewModel.

firestore.collection("users").document(user.uid).collection("medications").document()
}
selectedMedicine.medicationID = document.id
selectedMedicine.id = document.id
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.

Changed selectedMedicine.medicationID to id to reflect the existing constructor/attribute that is in the Medicine DTO

Copy link
Copy Markdown

@discospiff discospiff Apr 3, 2023

Choose a reason for hiding this comment

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

Either one works. No significant change to technical debt.

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.

Having the constructors set to val, or read only, was causing a compiling error when trying to run the program. Making it writable resolved the error.

app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="100dp"
tools:text="Medicine Name" />
tools:text="Medication Name" />
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.

Changed Medicine lines to Medication. Medication was used more frequently in the app then medicine was, so making this change made the UI more consistent.



</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout> No newline at end of file
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 an end of line for the androidx.constraintlayout.widget.ConstraintLayout block

@wrytherUC wrytherUC marked this pull request as ready for review April 2, 2023 21:40
Comment on lines -6 to +15
val id: String = "",
val uid: String = "",
val name: String = "",
val quantity: Int = 0,
val prescriptionStrength: String = "",
val startDate: LocalDate = LocalDate.now(),
val prescriptionLength: String = "",
val time: Long = 0,
var id: String = "",
var uid: String = "",
var name: String = "",
var quantity: Int = 0,
var prescriptionStrength: String = "",
var startDate: LocalDate = LocalDate.now(),
var prescriptionLength: String = "",
var time: Long = 0,
// Frequency per 24 hours
val frequency: Int = 0) {
var frequency: Int = 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Leave this as it were. Assume variables are immutable (val), unless we have a very good reason for reassigning them.

@discospiff
Copy link
Copy Markdown

I don't recommend merging this branch. Some of the recommendations increase tech debt instead of decreasing it.

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