3 ms·
Congrats, you just inherited this code and have to fix it: Mercury 0.378,2439.7,3.3e23,57910000,88,0.0000000001,0,false There is no way to infer what any
by sethammons 3y ago
Congrats, you just inherited this code and have to fix it:
Mercury 0.378,2439.7,3.3e23,57910000,88,0.0000000001,0,false
There is no way to infer what any of the values are. They are practically magic numbers. How do you know if you swapped a pair of numbers there and what that will do to the application? You have to mentally map all those things.
It is vastly, overwhelmingly more new-dev friendly to use:
MERCURY: Planet{
planet: mercury,
Gravity: 0.378,
RadiusKm: 2439.7,
MassKg: 3.3e23,
OrbitKm: 57910000,
OrbitDays: 88,
SurfacePressureBars: 0.0000000001,
Moons: 0,
Rings: false,
},
- zarldev 3y agothe values are specified in the definition of the iota type. ``` type planet int // Gravity[float64],RadiusKm[float64],MassKg[float64],OrbitKm[float64],OrbitDays[float64],SurfacePressureBars[float64],Moons[int],Rings[bool] ```
- sethammons 3y agoyeah, and now, mentally count how many values you are in, don't lose count now! Why offload that to your brain where you could miscount instead of using structured data?
- rat9988 3y agoBecause your whole argument is misconstructed. There are cases where longer code is better, but there are many cases where longer is worse too. Because the tools the language provide, on top of being more succint, make the intent more obvious.
- Debilski 3y agoI’m wondering why we don’t use any type and definition-aware IDEs that could render the first line as a proper table (especially once there is a list of items of the same type involved). With headers and aligned fields. Similar to how Word would do it with inline tables. Ideally of course with a switch to change to the second, more verbose definition.
- CharlieDigital 3y agoRider (and probably all JetBrains IDEs?) have inlined parameter names and types as hints. https://www.jetbrains.com/help/rider/Inline_Parameter_Name_Hints.html https://www.jetbrains.com/help/rider/Inline_Parameter_Name_H...
- MSFT_Edging 3y agoThat would tie languages to language tools and IMO be a downgrade from having a slightly more verbose language that is independent of tooling.
- zeven7 3y agoMaybe this data should be stored in a CSV and edited in Google Sheets/Excel.
- hbogert 3y agoI've got a job for you, mine at my previous company!