Where are the unit tests?
Twenty five thousand dollars of funny money
31–40 of 175 posts
Re: Twenty five thousand dollars of funny money
#32I understand this whole scenario is simplified for story's sake but, if there's old_func and new_func, and the new_func call in the else was added that morning, why would the same error of new_func getting the wrong amount of arguments happen weeks before?
Re: Twenty five thousand dollars of funny money
#33I'm gonna be honest, I had never understood the "strict type" argument until right now. Seriously, since everything I work in is denoted as "cents" from backend to frontend, I personally had never understood the need so I'm part of today's lucky 10,000th.
Seriously, since everything I work in is
denoted as "cents" from backend to frontend,
I personally had never understood the need
This matches my experience.Obviously actual strict typing has its benefits, but as far as developer ergonomics are concerned, IME you can get about 95% of the benefits just by following a convention of including unit names in identifier names.
It's easy to see why this Ruby code might fail:
def launch_rocket(distance)
# what units are we expecting?
end
launch_rocket(42)
But this is virtually impossible to screw up, and reduces developer cognitive load: def launch_rocket(distance_km:)
# blahblahblah
end
# not happening unless developer consumes a large number
# of drugs
distance_miles = 42
launch_rocket(distance_km: distance_miles)Re: Twenty five thousand dollars of funny money
#34I'm gonna be honest, I had never understood the "strict type" argument until right now. Seriously, since everything I work in is denoted as "cents" from backend to frontend, I personally had never understood the need so I'm part of today's lucky 10,000th.
COBOL was pretty good for dealing with money.
Re: Twenty five thousand dollars of funny money
#35Where are the unit tests?
People writing unit tests for internal tools? A lot of companies don't even having tests for production code.
It is code that deals with $'s... something you'd really want to test, since it'll cost the company money.
Instead, you've got multiple engineers writing code multiple times (my euphemism for fixing buggy code), which also costs the company money.
Re: Twenty five thousand dollars of funny money
#36I understand this whole scenario is simplified for story's sake but, if there's old_func and new_func, and the new_func call in the else was added that morning, why would the same error of new_func getting the wrong amount of arguments happen weeks before?
Re: Twenty five thousand dollars of funny money
#37Indeed. It's interesting that the de facto solution to this is to key value pairs, where sometimes the key can be an array (e.g. json, xml, etc), and then one can (kinda) infer units from the key. But even this is insufficient, because inevitably the value is pulled out and it's context is lost.
This is, I think, a(nother) powerful argument for immutable values, and accreting structure losslessly with pointers. Like in Clojure. In general we our runtime should support values that have monotonically increasing amounts of metadata added to them during runtime, for example units, or more paths, such that any user of the value can interrogate that structure and find out what it meant to the last people to read or write the value.
Re: Twenty five thousand dollars of funny money
#38Earlier quoted context omitted.
type RobotName = string; function foo(r: RobotName) {} ?
Yep. But that function will accept type RobotUuid = string; const bar: RobotUuid = “abc…”; foo(bar); This is what duck typing is and specifically my curiosity about being able to de-duck on demand.
Tho I suppose if it is really important you can put an assert there but I'm not familiar with that wrt typescript, maybe the transpiler would kill that?
I've done the occasional type checking in that way in similar languages, it is kind of self documenting too. 90% of the time duck typing is what you want.
Re: Twenty five thousand dollars of funny money
#39I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”
Re: Twenty five thousand dollars of funny money
#40Almost everything in the server-side that is related to times for a particular client uses milliseconds. Of course, redis’s `SETEX` does not. It uses seconds.
The data got quite stale. But, much like this post, other bugs were uncovered and usefully fixed.