I think it's generally best to use two functions and would perhaps ask you whether or not you really need a dedicated getter. Otherwise you could call your function *accessFoo* and have it either get or set the value accordingly. I guess creating that object instance is another matter as well. Are we even talking about instanciated "custom" objects? Because if we're not, then what's the use of having getters and setters? If we are, what type of objects are you trying to model... and what properties do you want to get / set?
Tobias. On Wednesday, 23 October 2013 20:27:47 UTC+2, Yakov wrote: > > Hello guys, > > I've got a code styling question, so may be it's ok to post it here, > although it can be discussed without the TiddlyWiki context? > > Here's the case: in a TW plugin, I need a setter and a getter function(s) > -- normally they don't do much more than store.getValue and store.setValue, > but in some special cases they do additional stuff. I feel it really > convenient while coding to have one function which does both things -- it > works as getter if the last parameter is undefined, and as setter > otherwise. This technique is used in jQuery in some methods like data. > However, I'd like to name my function *starting with a verb* and > currently I use an ugly name gsetCounter (get/set counter). What would > you recommend in this case? Any more suitable name? Any reasons why I have > to use two functions (aside this naming issue)? > > Best regards, > Yakov. > -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/tiddlywikidev. For more options, visit https://groups.google.com/groups/opt_out.
