4 ms·
Just argument parsing makes my eyes bleed... https://github.com/mrc-ide/covid-sim/blob/master/src/CovidSim.cpp#L146 https://github.com/mrc-ide/covid-sim/blob/m
by mshook 6y ago
Just argument parsing makes my eyes bleed...
https://github.com/mrc-ide/covid-sim/blob/master/src/CovidSim.cpp#L146 https://github.com/mrc-ide/covid-sim/blob/master/src/CovidSi...
That stuff is priceless:
else if (argv[i][1] == 'C' && argv[i][2] == 'L' && argv[i][3] == 'P' && argv[i][4] == '1' && argv[i][5] == ':')
I guess string comparisons are complicated. I also fail to see why they used ':' as the separator and why they didn't use a proper library to parse argv...
- tasogare 6y agoBecause when you have only a very limited number of arguments it’s easier to do it that way than selecting a lib, adding it to the project, reading the doc, trying it and integrating it for real. I add the issue in C#, and after trying 2 or 3 libs (including one by Microsoft) I just gave up.
- mshook 6y agoI hear you but in their case they have more than 130 LOC to parse ARGV. Doing all that manually hurts both code readability and maintainability.
- notkaiho 6y agoHaving seen a discussion about this on a different forum, someone who used to work in academia mentioned that repeatability and consistency are key to academic code, which means often readability and convention may get sacrificed - it works for the author and if someone wants to repeat the experiment it should get the same results without wangling around with many external packages or modules that may change or become obsolete. Still hurts to read though :P
- tasogare 6y agoYep. Also, speaking from academic point of view, code won’t make you advance on your career by itself (only papers based on it will), so the minimum is done until the thing is usable for its goal. So forget about CI/CD, proper test suits, documentation (I hate this point personally and document my projects a bit more than the average researcher) and engineering best practices.
- jfnixon 6y agoThen public policy should heavily discount results based on academic code, if it shown to be poorly engineered. I'd go further and say you can't trust the papers based on the results of badly engineered simulations. As a poster said earlier "I think there should be fairly high standards of scientific rigor even in published code, especially if this might impact public policy actions, like we should expect high rigor in biological and epidemiological studies."
- notkaiho 6y ago...what do you think those biological and epidemiological studies hinge on? ;)