language agnostic - 6 abstractions, 1 construct -
which prefer, , why:
typical
if (this.sun.hidden === true && this.moon.visible === false) { print "its daytime" } possible unnecessary abstraction
if (issunhidden() === true && ismoonvisible() === false) { print "its daytime" } removing syntax
if (issunhidden() && ismoonvisible()) { print "its daytime" } i 1 readable, requires hard-coded "daytime" string
if (timeofday() === "daytime") { print "its daytime" } this easy read
if (isitdaytime()) { print "its daytime" } mixes printing time of day checking, not good
printdaytime(); anyway, personal preference large degree, there good, logical reasons prefer 1 on other , interested in hearing reasons - or possibly other variations of same construct if adds anything.
thanks!
of options, prefer:
if (isitdaytime()) { print "its daytime" } this 1 not terrible:
if (timeofday() === "daytime") { print "its daytime" } ...though use enumeration or similar construct instead of literal string, like:
if (timeofday() === timeofday.day_time) { print "its daytime" }
Comments
Post a Comment