4 ms·
> I assert that there is no current objective metric where you can plug in source code and get out some sort of comprehensibility value. Ratio of ternary opera
by CharlieDigital 3y ago
> I assert that there is no current objective metric where you can plug in source code and get out some sort of comprehensibility value.
Ratio of ternary operators more than 1 level deep to total LoC.
You know you're in for some pain when you randomly open a file and the ternary expressions go 6 levels deep.
- Verdex 3y ago> Ratio of ternary operators more than 1 level deep to total LoC. Sure. I should have said, "no current general objective metric". For example, if we detect any symbols longer than 6 billion characters, then we know the code is likely to be hard to grok. Or if the only character used in symbols is the underscore. And maybe the path forward for determining objectively comprehensible code is to collect every pathological case and then good code is code without the bad stuff. But I personally hope for a general solution that we can setup which will emergently determine that too many nested ternary operators is bad from first principles. I'm more than ready to be disappointed when this turns out not to be possible, but everyone is allowed a dream.
- bluGill 3y agoSure, but the vast majority of programmers don't do that type of thing. Often in cases like the above I'm not sure if the metric is correct - or is it just that you are not used to reading that style. For years I worked at places that banned the ternary expression and so I didn't use them and it was a lot of work to remember what was going on the rare times I saw them. Then I got a job on the team that did use them all the time (but never more than 1 level deep) and I soon learned to read them and now I use them often where they make sense.