2 ms·
You're kinda arguing against yourself as the code won't be consistent. You're changing a part of your code but not all of it and it just leads to brittle code a
by mattmanser 13y ago
You're kinda arguing against yourself as the code won't be consistent. You're changing a part of your code but not all of it and it just leads to brittle code as you're never sure what you're working with, especially in a dynamically typed language like javascript with terrible support for editor behaviour sniffing.
Every time you have an object you have to remember whether it's a normal JS object or a properties-as-methods object. Using knockout to handle your view models doesn't magically change the rest of your code. All the other code you write and libraries you use will be using properties the standard way.
Secondly, the uniform access principle (which you seem to misquoting? It's not about consistent access by type, it's about all types having identical methods of access).
It comes across as something an academic would propose because it's intellectually enticing but practically detrimental.
Think of it like changing a, it, the, we, you, our, etc. all to be o. Yeah, now you can change nouns freely, but the syntax is a signal and the difference is useful.
A method is conceptually supposed to be different to a property and so it should look different.
Javascript's bad enough for readability with everything being a function.
Whether you agree with it or not, in the end it's simply not how javascript works. Methods and properties are accessed differently.