that you have failed to write code that was expressive enough. You should feel a sharp pain in your stomach every time you write a comment." @AdamMc331 #DCNYC19 4
that we need to be consistent * in all WebViews of our app. * For some URLs, though, we need additional customization so we * can extend this base class accordingly. */ class BaseWebViewClient(...) : WebViewClient @AdamMc331 #DCNYC19 8
account into the database. * * @param[account] The account that we're inserting. * @return The ID of the inserted account. */ fun insert(account: Account): Long } @AdamMc331 #DCNYC19 10
an account into the database. * * @param[account] The account that we're inserting. * @return The ID of the inserted account. */ fun insert(account: Account): Long } @AdamMc331 #DCNYC19 20
updated questions to be replaced in our list by an interceptor. */ private val updatedQuestions: MutableMap<Long, Question> = HashMap() @AdamMc331 #DCNYC19 27
from Android is backed by an immutable list. * However, if the user answers a question locally, we want to update the display * without having to fetch the data from the network again. * * To do that, we keep this local cache of questions that the user has * answered during this app session, and later when we are building * the list we can override questions with one from this list, if it exists. * That's determined by the key of this HashMap, which is the question ID. */ private val updatedQuestions: MutableMap<Long, Question> = HashMap() @AdamMc331 #DCNYC19 28
name of the Pokemon. */ fun addPokemon(name: String, number: Int) { } } Better: With Examples class Pokedex { /** * @param[name] The name of the Pokemon (Bulbasaur, Ivysaur, Venusaur). */ fun addPokemon(name: String, number: Int) { } } @AdamMc331 #DCNYC19 30
does not support a * specific functionality that we need. We've extended * this class to modify it ourselves. * * Issue reported: https://github.com/library/issues/1 */ class MyCustomCarousel : Carousel() { // ... } @AdamMc331 #DCNYC19 34
create accountability with links to issue trackers. //TODO: Consolidate both of these classes // since we only have one activity now. // AAA-123 class MainActivity : BaseActivity() { // ... } @AdamMc331 #DCNYC19 36
Pokemon. */ val firstType: Type? get() = currentState.pokemon?.sortedTypes?.firstOrNull() Refactor class name... /** * Retrieves the primary Type for a Pokemon. */ val firstType: PokemonType? get() = currentState.pokemon?.sortedTypes?.firstOrNull() @AdamMc331 #DCNYC19 43
[Pokemon]. */ val firstType: Type? get() = currentState.pokemon?.sortedTypes?.firstOrNull() Refactor class name... /** * Retrieves the primary [PokemonType] for a [Pokemon]. */ val firstType: PokemonType? get() = currentState.pokemon?.sortedTypes?.firstOrNull() @AdamMc331 #DCNYC19 44
signed on within the last 24 hours. */ fun isActive(): Boolean { // ... } /** * @return False if the user is not a staff member for our team. */ fun isStaff(): Boolean { // ... } @AdamMc331 #DCNYC19 46
signed on within the last 24 hours. */ fun isActive(): Boolean { // ... } /** * @return True if the user is a staff member of our team. */ fun isStaff(): Boolean { // ... } @AdamMc331 #DCNYC19 47