View Single Post
05/28/14, 04:28 AM   #9
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
The main intent of the "Does it need to be optimised?" part is you don't go making your code more complex (and error-prone) to get a little bit of optimization. What do you gain by combining your get/set functions besides making it needlessly complex? KISS - Keep it simple stupid.

Even though you don't get the full read-only guarantees on getters like you can in C++, it makes your API clearer. You can easily say "The get function has no side effects."

For example, what happens if you want to actually use NIL as a value? There is no way to signal this to your getset combined function. What's worse is it will happily return a value silently and proceed on its way with no warnings. If you get a NIL passed in, you'll only see the results later of a NIL not being stored (not in a clean error message) and it could be a difficult bug to notice and track down.

(PS: Doesn't mean you should abandon a MVVM pattern, just keep it with traditional get/set functions.)
  Reply With Quote