You are currently viewing Coding Style

Coding Style

I have been working on a few Android apps in Kotlin to place in my resume and I have deviated from the colon spacing rule listed here, as well as spacing in general.

An example:

val currencySymbolKey : String = sp[Constants.KEY_CURRENCY_SYMBOL , "dollar"]!! val dateFormatKey : String = sp[Constants.KEY_DATE_FORMAT , "0" ]!! val decimalSymbolKey : String = sp[Constants.KEY_DECIMAL_SYMBOL , "period"]!! val thousandsSymbolKey : String = sp[Constants.KEY_THOUSANDS_SYMBOL, "comma" ]!! val decimalPlaces : Boolean = sp[Constants.KEY_DECIMAL_PLACES , true ]!! val symbolSide : Boolean = sp[Constants.KEY_SYMBOL_SIDE , true ]!! 

Another:

val currencySymbol : String = getCurrencySymbol (currencySymbolKey ) val dateFormat : Int = getDateFormat (dateFormatKey ) val decimalSymbol : Char = getSeparatorSymbol(decimalSymbolKey ) val thousandsSymbol : Char = getSeparatorSymbol(thousandsSymbolKey) 

The rule states that colon should have no spaces when declaring a variable and its type, but I like the way it looks when they are lined up as shown above. I find it easier to read compared to:

val currencySymbolKey: String = sp[Constants.KEY_CURRENCY_SYMBOL , "dollar"]!! val dateFormatKey: String = sp[Constants.KEY_DATE_FORMAT, "0"]!! val decimalSymbolKey: String = sp[Constants.KEY_DECIMAL_SYMBOL, "period"]!! val thousandsSymbolKey: String = sp[Constants.KEY_THOUSANDS_SYMBOL, "comma"]!! val decimalPlaces: Boolean = sp[Constants.KEY_DECIMAL_PLACES, true]!! val symbolSide: Boolean = sp[Constants.KEY_SYMBOL_SIDE, true]!! 

My question is whether or not this is good coding practice. Should I go back and remove all unnecessary white space? The only time I do this is when defining multiple variables at once as shown above.

submitted by /u/PacoDaTacoSeller
[link] [comments]