Programmer Life

The 7 Coding Styles That Are Dated

I was a firm believer in them but now I am converted.

Elye - A One Eye Dev By His Grace
The Startup
Published in
6 min readAug 18, 2020

--

Picture by geralt on Pixabay

If you have been coding for more than a decade, you might have some preferred styles that you firmly believe in and stood by with your arguments to defend them till the end.

Below are some of them that I once stood by firmly once, but now I think I have to let it go.

1. Use m or this to indicate member variables

Rule: To differentiate member variables from local variables, use either one of the following

  • The use of Hungarian notation i.e. mMemberVariable vs localVariable. Where m stands for member variable.
  • The use of this i.e. this.memberVariable vs localVariable.

Past reason

The reason was when we read code, we can easily know if they are member variables or local variables without looking at their declaration.

class MyClass {
var mMember = "member"

fun doSomething() {
val local = "local"

println(this.mMember)
println(local)
}
}

Now

If modern IDE, such text-based distinction is no longer required. See the same code…

--

--