Skip to content

Instantly share code, notes, and snippets.

@yogacp
Last active May 21, 2019 08:57
Show Gist options
  • Save yogacp/cfb6e21791021541348fe8c5ecd856d8 to your computer and use it in GitHub Desktop.
Save yogacp/cfb6e21791021541348fe8c5ecd856d8 to your computer and use it in GitHub Desktop.
Sample of how to create meaningful names
// Bad variables naming
var a = 0 // user ages
var w = 0 // user weight
var h = 0 // user height
// Bad functions naming
fun age()
fun weight()
fun height()
// Bad classes naming to get user data
class UserInfo()
// Best practices varibales naming
var userAge = 0
var userWeight = 0
var userHeight = 0
// Best practices functions naming
fun setUserAge()
fun setUserWeight()
fun setUserHeight()
// Best practices classes naming to get user data
class User()
@Zhuinden
Copy link

The user prefix is redundant if these are variables/functions of the User class.

@bigman212
Copy link

bigman212 commented May 21, 2019

Also, maybe you should change signature of "setUser..." and insert parameters. Like:

fun setUserAge(newAge: Int)
fun setUserWeight(newWeight: Int)
fun setUserHeight(newHeight: Int)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment