Coding with Jesse 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": "5af6c4357c785fe0ddee50289c2bfe72473478e41fca768ae5293ed5244c908c",
"pubkey": "5ca2632a0b8688e350b28ec4dba06b2a92fde85eb49f503f29b4b2295a121bf7",
"created_at": 1718376448,
"kind": 1,
"tags": [
[
"proxy",
"https://toot.cafe/@JesseSkinner/112615518909652017",
"web"
],
[
"proxy",
"https://toot.cafe/users/JesseSkinner/statuses/112615518909652017",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://toot.cafe/users/JesseSkinner/statuses/112615518909652017",
"pink.momostr"
]
],
"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": "1a6fdcbb9a2376e8c81a3b1cc427084e3ddc51fbf7e0ce83da3d620126b515c1dae4e1c0b22ea0a1877a44bdcda1b84c31160af7eb514dfa8bbd60e4ddfd9844"
}