Jesse Skinner :javascript: on Nostr: Why does so much "refactoring" essentially boil down to changing this: function a() { ...
Why does so much "refactoring" essentially boil down to changing this:
function a() {
doOneThing()
}
function b() {
doAnotherThing()
}
into this:
function a() {
doThing('one')
}
function b() {
doThing('another')
}
function doThing(type) {
if (type === 'one') {
doOneThing()
} else if (type === 'another') {
doAnotherThing()
}
}
If your "code reuse" is increasing the amount of code, you're probably doing it wrong.
Published at
2024-06-14 14:47:28Event JSON
{
"id": "e7ed6d7500f24f5fa3e91e5cf24924628cca5de790890e1c141815f8a19b8aa4",
"pubkey": "ec950969771e5eb6e15d6bc17a97111aeaeb1088823b745be222344f1825f630",
"created_at": 1718376448,
"kind": 1,
"tags": [
[
"proxy",
"https://toot.cafe/users/JesseSkinner/statuses/112615518909652017",
"activitypub"
]
],
"content": "Why does so much \"refactoring\" essentially boil down to changing this:\n\n function a() {\n doOneThing()\n }\n function b() {\n doAnotherThing()\n }\n\ninto this:\n\n function a() {\n doThing('one')\n }\n function b() {\n doThing('another')\n }\n function doThing(type) {\n if (type === 'one') {\n doOneThing()\n } else if (type === 'another') {\n doAnotherThing()\n }\n }\n\nIf your \"code reuse\" is increasing the amount of code, you're probably doing it wrong.",
"sig": "9f78f7a7cfbb2767f72e00d63e98105c1f2d319dbe5d33af99a94372f2dae8e77aa3b4758c81b9aba698dfa72b9ff2b6b7acaa63468df296f835b74acdeb003d"
}