|
|
|
|
|
by zamadatix
1739 days ago
|
|
I'm not following how moving the options out of the function parameters and into the call chain makes the actual function more maintainable. It's still doing the exact same thing with the exact same options it's just pulling them from elsewhere. If anything you now have more functions to maintain on top of the function that does many different things based on the calling info. // The original "misses the point"
trig(mode="cos", type="hyperbolic")
// The style fetch() uses today
trig({mode: "cos", type: "hyperbolic"})
// The builder refactor
trigBuilder().withMode("Cos").withType("hyperbolic").calculate()
|
|
the difference, IMO, is - in Javascript - that this
would fail silently while would trigger a compilation errorbut, IMO, passing objects is good enough most of the times, and I consider it a much better solution over passing boolean flags