Post AzKPyiwGPbi4ZOJ6QK by huxley@furry.engineer
(DIR) More posts by huxley@furry.engineer
(DIR) Post #AzKNZ1BZkQkviy5Gcq by foone@digipres.club
2025-10-18T08:18:41Z
1 likes, 0 repeats
one urge I have a lot of trouble avoid while programming is to have my code maintain compatibility with earlier versions of itself, when there's no external users that would require that compatibility
(DIR) Post #AzKNnJIdCKqTxQCPdA by foone@digipres.club
2025-10-18T08:21:19Z
0 likes, 0 repeats
example:the code I'm working on now is a standalone python script that has a function named getGIFName:def getGIFName(orig_name):it takes one argument, the filename you want a GIF version of (so like "foobar.mp4" => "foobar.gif"but I'm now changing it to support more formats than GIF, so I changed it to:def getOutputFilename(orig_name, format):so now you pass "foobar.mp4","webp" and get "foobar.webp"
(DIR) Post #AzKNrbk8ZCtsJl78Qy by foone@digipres.club
2025-10-18T08:22:03Z
0 likes, 0 repeats
and I get the automatic urge to make it:def getOutputFilename(orig_name, format='gif') so that it'll stay compatible with the old API.
(DIR) Post #AzKNugAcYyymuuxy5o by foone@digipres.club
2025-10-18T08:22:25Z
1 likes, 0 repeats
except the old API is only ever called from THIS SAME SCRIPT and I can just CHANGE THE PLACES I CALL IT. (all one of them)
(DIR) Post #AzKNxxClgYJecMX37g by foone@digipres.club
2025-10-18T08:23:08Z
0 likes, 0 repeats
I'm not even collaborating with anyone on this code, who might write some code thinking the function still had only one argument
(DIR) Post #AzKO0uReP3xKvVu1E8 by foone@digipres.club
2025-10-18T08:23:32Z
1 likes, 0 repeats
it makes no sense.but I'm always catching myself wanting to do this whenever I refactor my own code.
(DIR) Post #AzKOATg0mYnGnmBMRM by Netux@mastodon.sdf.org
2025-10-18T08:25:27Z
0 likes, 0 repeats
@foone or leave the old name as a wrapper with the default extension.
(DIR) Post #AzKPcaq7qLa752spNI by petealexharris@mastodon.scot
2025-10-18T08:41:46Z
0 likes, 0 repeats
@foone Maybe as well as it being a (usually good) habit, some parameters just feel like "the main thing" so get to be positional and some feel like options so get to be keywords?
(DIR) Post #AzKPtc6wN0tVwhreYS by kenran_@mas.to
2025-10-18T08:44:52Z
0 likes, 0 repeats
@foone I can relate 😅 For some "bigger" projects I've tried to find out why I do this. My personal conclusion: I can do the refactoring in 2 steps and thus 2 smaller commits, which generally I prefer. Other than that it's just a spleen I guess 🤷♂️
(DIR) Post #AzKPyiwGPbi4ZOJ6QK by huxley@furry.engineer
2025-10-18T08:45:44Z
0 likes, 0 repeats
@foone in case you're looking for reasons to give yourself not to do this: default values are a bad practice anyway! And breaking API helps library consumers know what call sites to update to avoid hidden behavior changes. Personally I have been finding that breaking developers prevents breaking users. It's annoying to have to defend your API changes but developers are better equipped to handle change than users are.
(DIR) Post #AzKTEBU8rK9HJMDWHA by uliwitness@chaos.social
2025-10-18T09:22:05Z
0 likes, 0 repeats
@foone I have that tendency when there are multiple call sites and I don't have reliable refactoring, but usually I fight it in that case, as it's just laziness.OTOH, I wouldn't do this for the example you gave, because the new name getOutputFilename() is ambiguous. (It says GIF nowhere).It's a good habit to have in network protocols or file formats, though. Ensure it can upgrade any newly-added values, even ones I made during development and forgot (although I will often error there).