Android Development Best Practices: Productivity Guide

Bartosz Kraszewski
Jun 13 · 6 min read

Use Preview tab for checking UI

Use unit test for testing pure, android free code

data class User( val name: String, val id: Long)data class MeetingDetails(
val meetingOwnerName: String,
val meetingOwnerId: Long,
val canCancel: Boolean)
fun processMeetingInfo(attendees: List<User>, currentUser: User, ownerId: Long): MeetingDetails
@Test
fun shouldAllowCancelMeetingIfCurrentUserIsOwner(){
//setup phase
val currentUser = User(“Joe”, 1)
val attendees = listOf(User(“Joe”, 1), User(“Jane”, 2))
//evaluation phase
val meeting = processMeetingInfo(attendees, currentUser, 1)
//assertion phase
assertTrue(meeting.canCancel)
}

Fake it ‘till you make it

fun shouldShowOnboarding(prefs: SharedPreferences): Boolean{
//return prefs.contains(ONBOARDING_SHOWN)
// TODO — just for testing, remove before going to production!
return false
}

Quick Summary


Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade