Sorry, I made that sound backwards. It will only grab a field if that field is public. So, you can start out with direct field accessors, but then change to a getter without having to change any of the calling code.

Better, but still not really a fan, I think.

I’m not super fluent in JS, but I’m fairly sure that for a public property, you can say = value

If that property becomes private and you create a set method instead, you have two choices on how to do things:

Either = value no longer works, in which case we’re back where we started

Or it does still work, in which case it looks to the API user like they’re modifying the property directly, which can lead to confusion if the actual fact of the situation is that they’re touching a piece of logic that just, incidentally, also sets the property but can do other things as well.

I’m sure there’s a use case, the designers probably aren’t fools, but I don’t like it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s