DEV Community

loading...

Discussion on: We Should All Be Writing WET Code

Collapse
darkwiiplayer profile image
DarkWiiPlayer

If you set two variables in your function, is it no longer doing "one thing"?

I think that thought is a bit misleading: functions serve as an interface between two levels of abstraction and the "do one thing" rule should apply mostly on the level of the caller, not the internals of the function.

A function (or any other type of subroutine, really) might do lots of things internally that present present as a single atomic action to the outside.

Also, there's one statement that can be generalized a bit:

But any time you start [insert almost any best practice here] the heck outta stuff, you're almost never doing it well.

See? Much more DRY now 😁

Forem Open with the Forem app