4 ms·
Literally an example from today: updateDescription(image) { let description = window.prompt( "Update description", image.desc
by earthboundkid 7y ago
Literally an example from today:
updateDescription(image) {
let description = window.prompt(
"Update description",
image.description
);
if (description !== null && description !== image.description) {
actions.doUpdate(image, { description });
}
},
updateCredit(image) {
let credit = window.prompt("Update credit", image.credit);
if (credit !== null && credit !== image.credit) {
actions.doUpdate(image, { credit });
}
},
I waffled on whether to deduplicate it or let it be. What was the Obvious Right Choice?
- KajMagnus 7y ago> I waffled on whether to deduplicate it or let it be. What was the Obvious Right Choice? What about adding a one line comment that this code can be refactored and improved, and how? But not doing anything immediately. If you run into this annoying code repeatedly, then, it can be worth taking the time to refactor it.
- earthboundkid 7y agoHmm, maybe I should wait until there are N examples of the pattern. Maybe 4 > N > 2 ??? :-D
- KajMagnus 7y agoWhat if N becomes 4 o.O then the weird code will be there forever? :- )