Skip to content

Raufha code review2#25

Open
SofwareDude wants to merge 7 commits intomasterfrom
raufha_CodeReview2
Open

Raufha code review2#25
SofwareDude wants to merge 7 commits intomasterfrom
raufha_CodeReview2

Conversation

@SofwareDude
Copy link
Collaborator

@SofwareDude SofwareDude commented Mar 29, 2022

Was the program available in UC Github on time?
Answer) Yes.

Is the program documented/commented well enough for you to understand?
Answer) Yes. It was easy to read and understand.

Does the program compile?
Answer) Yes, the code does compile but the IncidentUnitTest fails. Maybe due to the unit test not knowing what firebase is.

The rationale behind your changes.
Answer) The code is mostly reformating, logic simplification, some deletion of not used imports, and updating an implementation.

My commits.
Smoofington/FindMyRecyclingV32001@56e4915
Smoofington/FindMyRecyclingV32001@56e4915
Smoofington/FindMyRecyclingV32001@5ac93f1
Smoofington/FindMyRecyclingV32001@69030d9
Smoofington/FindMyRecyclingV32001@953fb34

What I learned from this code review.
Answer) Further improvement on how to debug Kotlin code. Learned how to format according to Kotlin conventions. Naming conventions in Kotlin, and logic simplification in Kotlin. Learned how lambda functions work and what "it" does.

implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to the latest version to 2.4.1 as per IDE and the professor's lecture video recommendations.

Comment on lines -9 to -10
//TO DO: single<IIncidentService> { IncidentService }
//TO DO: add "get()" as the parameter in the MainViewModel in line 8
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not a serious issue but it is better to give space when commenting as per Kotlin convention. https://kotlinlang.org/docs/coding-conventions.html#horizontal-whitespace

private var firebaseUser: FirebaseUser? = FirebaseAuth.getInstance().currentUser
private var selectedIncident: Incident? = null
private val viewModel : MainViewModel by viewModel<MainViewModel>()
private val viewModel: MainViewModel by viewModel()
Copy link
Collaborator Author

@SofwareDude SofwareDude Mar 29, 2022

Choose a reason for hiding this comment

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

Deleted the space from the colon as per Kotlin conventions and after running the debugger MainViewModel in angular brackets was not necessary. https://kotlinlang.org/docs/coding-conventions.html#colon

Comment on lines 60 to +63
Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
Row(Modifier
.padding(5.dp),
Row(
Modifier
.padding(5.dp),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reformated the code for easier and more consistent reading. https://kotlinlang.org/docs/coding-conventions.html#formatting

Comment on lines -66 to +70
ExtendedFloatingActionButton (
text = { Text(text = "Report Incident") },
onClick = { val intent = Intent(context, ReportIncidentActivity::class.java)
ExtendedFloatingActionButton(
text = { Text(text = "Report Incident") },
onClick = {
val intent = Intent(context, ReportIncidentActivity::class.java)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines -38 to +37
fun initMocksAndMainThread(){
fun initMocksAndMainThread() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines -51 to +50
fun `given a view model with live data when populated with incidents between 2019 and 2020, in state 40, county 1, results show incident with caseId 400132`(){
fun `given a view model with live data when populated with incidents between 2019 and 2020, in state 40, county 1, results show incident with caseId 400132`() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines -60 to -62
incidents.add(Incident(stateId = 40, stateName = "Oklahoma", caseId = "400132", countyId = 1, countyName = "Adair", latitude = "35.64110000", longitude = "-94.678300000"))
incidents.add(Incident(stateId = 40, stateName = "Oklahoma", caseId = "400429", countyId = 1, countyName = "Adair", latitude = "35.98840000", longitude = "-94.655000000"))
incidents.add(Incident(stateId = 40, stateName = "Oklahoma", caseId = "400434", countyId = 1, countyName = "Adair", latitude = "35.82660000", longitude = "-94.613000000"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines -75 to +107
var allIncidents : List<Incident>? = ArrayList<Incident>()
var allIncidents: List<Incident>? = ArrayList<Incident>()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines -90 to +122
if(it.caseId.equals("400132")){
if (it.caseId == "400132") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines +4 to +18
internal val CITY: String? = "",
internal val CITY_NAME: String? = "",
internal val COUNTY: String? = "",
internal val COUNTRY_NAME: String? = "",
internal val CASE_YEAR: String? = "",
internal val FATALS: String? = "",
internal val LATITUDE: String? = "",
internal val LONGITUDE: String? = "",
internal val STATE: String? = "",
internal val STATE_NAME: String? = "",
internal val ST_CASE: String? = "",
internal val TOTALVEHICLES: String? = "",
internal val TWAY_ID: String? = "",
internal val TWAY_ID2: String? = "",
internal val VE_FORMS: String? = "",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added = ""

data class IncidentListDTO(
val Count: Int = 0,
val Message: String,
val Message: String = "",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added = ""

Comment on lines 4 to 5
val uid: String = "",
var displayName: String? = "",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added = ""

Comment on lines 4 to 18
internal val CITY: String? = "",
internal val CITY_NAME: String? = "",
internal val COUNTY: String? = "",
internal val COUNTRY_NAME: String? = "",
internal val CASE_YEAR: String? = "",
internal val FATALS: String? = "",
internal val LATITUDE: String? = "",
internal val LONGITUDE: String? = "",
internal val STATE: String? = "",
internal val STATE_NAME: String? = "",
internal val ST_CASE: String? = "",
internal val TOTALVEHICLES: String? = "",
internal val TWAY_ID: String? = "",
internal val TWAY_ID2: String? = "",
internal val VE_FORMS: String? = ""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually reverted this and added = "" in another commit.

Comment on lines 5 to 7
val Message: String = "",
val Message: String,
val Results: List<List<IncidentDTO>>,
val SearchCriteria: String = ""
val SearchCriteria: String,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually reverted this and added = "" in another commit.

Comment on lines 4 to 5
val uid: String = "",
var displayName: String?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually reverted this and added = "" in another commit.

Comment on lines -43 to -44
newIncident.longitude = it.LONGITUD ?: ""
newIncident.caseId = it.ST_CASE ?: ""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Typo and spacing.

Comment on lines -47 to +55
newIncident.vehiclesInvolved = if(it.TOTALVEHICLES != null) it.TOTALVEHICLES.toInt() else 0
newIncident.vehiclesInvolved =
if (it.TOTALVEHICLES != null) it.TOTALVEHICLES.toInt() else 0
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Broke a long line into two.

val TWAY_ID2: String? = "",
val VE_FORMS: String? = ""
internal val CITY: String? = "",
internal val CITY_NAME: String? = "",

Choose a reason for hiding this comment

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

Good. Use _ in constants.

var rule: TestRule = InstantTaskExecutorRule()

lateinit var incidentService : IncidentService
//var allIncidents : IncidentListDTO? = IncidentListDTO(Results = ArrayList<List<IncidentDTO>>())

Choose a reason for hiding this comment

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

Good suggestion.

Avoid pushing commented code to Version Control. Version control has tools that makes this unnecessary.

  • You can look at history to see what used to be there.
  • You can use branches for experimental features.

@discospiff
Copy link

A few good suggestions worth reviewing.
Reformatting can be performed automatically by the IDE. No need to create a separate branch for this. Just let the IDE do it, and it will be consistent for all developers.

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