Ideally, any function should be idempotent and maximally expressive. If I'm reading code and I hit setState(bool) then I have to go find where the bool is set. toggle() is worse. Foo.enable() is perfect because when I hit that code I only need ordinary domain knowledge to understand. Similarly, prefer isEnabled() to getState(). IsDisabled() is a little iffy, but I like it because it helps streaming functions to read a bit easier to have both, but it depends on the language you're using. Java is notorious for its verbosity, but I like it.
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments