And while searching for a reference, I found the original Qt Quarterly, archived here: https://doc.qt.io/archives/qq/qq13-apis.html - I am sure some of it is just hopelessly outdated, but the general insights probably still hold up. There's a probably-more-modern successor here on their wiki: https://wiki.qt.io/API_Design_Principles
I keep tripping over "true, false, true"
31–40 of 62 posts
Re: I keep tripping over "true, false, true"
#32AI;dr: keyword arguments would be great in all languages, not just Smalltalk Also, obviously bot/bought account.
Re: I keep tripping over "true, false, true"
#33Re: I keep tripping over "true, false, true"
#34I was nodding along with the piece in the first half, then it repeated the same point five more times and I started to smell slop.
You can tell it was written by claude after just a few sentences, really.
Re: I keep tripping over "true, false, true"
#35CreateUser(CreateAdmin::enable);
Re: I keep tripping over "true, false, true"
#36> toggleMenu(true); That’s clear enough. the meaning is obvious so... it does toggle the menu? and toggleMenu(false) doesn't toggle it and keeps it as it is? or is it toggle extended menu vs toggle basic menu?
Re: I keep tripping over "true, false, true"
#371. Avoid long parameter lists [1]
2. Avoid boolean arguments [2]
For #1, long parameter lists should be named (named arguments, options object, etc).
For #2, and booleans should be replaced by meaningful enumerations.
> toggleMenu(true); That’s clear enough. the meaning is obvious
Actually, it's incredible ambiguous. Is that toggling the menu? Or setting it to the open state? Or something else? I have no idea.
setMenuState(MenuState.OPEN)
setMenuState(MenuState.CLOSED)
[1] https://testing.googleblog.com/2024/05/avoid-long-parameter-...[2] https://alexkondov.com/should-you-pass-boolean-to-functions/
Re: I keep tripping over "true, false, true"
#38Earlier quoted context omitted.
You can tell it was written by claude after just a few sentences, really.
Even the premise is ridiculous, inlay hints for parameter names have existed for a really long time. What human using a code editor could come up with this "problem"? The comments all seem to be nodding along and even suggesting absolutely hare-brained code like "const isThing = true; ...". I feel like I'm losing my mind. How many interactions on this site are sill organic? Am I talking to a bot right now?
fwiw, while inlay hints are great, they don't work in either git-delta or github, so they're not availabe in a good chunk of the places that I'm looking at code, so for TypeScript, I do lean towards object arguments with keys the way the article suggests.
Re: I keep tripping over "true, false, true"
#39Isn't this more an issue with typescript? Doesn't your ide give you the declaration if you hover over the call? > And I’ve seen real calls like this in production code: > updateSettings(user, true, false, true, false) Really? He wants named parameters on all function calls cos he's got a memory like a sieve? This is a long solved problem to me
Re: I keep tripping over "true, false, true"
#40Earlier quoted context omitted.
You can tell it was written by claude after just a few sentences, really.
Even the premise is ridiculous, inlay hints for parameter names have existed for a really long time. What human using a code editor could come up with this "problem"? The comments all seem to be nodding along and even suggesting absolutely hare-brained code like "const isThing = true; ...". I feel like I'm losing my mind. How many interactions on this site are sill organic? Am I talking to a bot right now?
1. Somewhat often, parameter hints just stop working. Why? Who knows! There never seems to be any way to debug these mechanisms. They just stop working and you're forced to do stuff like delete random cache folders or toggle random options, as suggested by randos from Stack Overflow posts in 2017, until it maybe starts working again (for now)
2. Parameter hints sometimes aren't available when you need them. Xcode, for example, only seems to be able to put them inline, as text in the document that you replace with the arguments, something available only when writing code. You can't get them to pop up on demand as a reader as you can with, say, Visual Studio
3. You might be examining the code in some kind of review UI, rather than a code editor, in which case you're going to have to do some back and forth. You might be right in the middle of something yourself, and not in a position to retrieve the code locally to examine it in the usual editing environment. (I don't think you should go overboard optimising for this case, but I think it worth considering)
4. From the type checker perspective, all bools are equivalent. If you pass "false" for one bool parameter, then you could just as well pass that same "false" for another one - complicating rearranging or adjusting parameters, because, depending on the type of change you make, you may not get a good set of diagnostics to work through. And it gets worse if you've got defaulted or optional parameters