Re:Stop Writing Reusable React Components
by nsonha on Sunday December 05, 2021 @08:21PM
(#29455130)
Honestly if your criticism to code reuse is all about DRY, and you equate code reuse with abstraction, then it should not be taken seriously.
Abstraction, code reuse and DRY are 3 different things. Abstraction is control, when you want the client code to conform to a pattern, so that it won't break your system. Code reuse can be either about convenience or control, can be abstraction related or not. For example when you reuse a function that perform a critical business logic, you don't do it to conform to an abstraction, nor to save time typing the function again. You do it because you want a single source of truth for that bit of logic.
Abstraction, code reuse and DRY are 3 different things. Abstraction is control, when you want the client code to conform to a pattern, so that it won't break your system. Code reuse can be either about convenience or control, can be abstraction related or not. For example when you reuse a function that perform a critical business logic, you don't do it to conform to an abstraction, nor to save time typing the function again. You do it because you want a single source of truth for that bit of logic.
Lastly DRY is purely about convenience.