Yep. Looks concise but is horrible to read. Not only that, but memory usage is O(n!) for this implementation since it stores every permutation of elements up to length n (9 in this case)
code that doesn't read like a sentence generally should be refactored until it does, as long as this is not done at the expense of required performance (keyword: required). this is a bit for your own sake, but mostly your colleagues. as much as people like to get bogged down in performance, it simply doesn't matter beyond "good enough" and that bar is not as high as some people think.
what's much more important is avoiding a situation where somebody looks at your code because they inherited it and loudly sigh in desperation.
good naming does most of the heavy lifting here, and since it's one year ago i assume you've learnt a bit since then. :)
For loop’s or lambda variables are the exception for me (I am also in c# so gotta love LINQ) although I am almost always going to use a foreach instead
It seems like everyone goes through this phase of trying to make everything a cryptic one-liner. Then a few months pass and you have to debug your own code and hate yourself.
One of the other "senior" engineers at my office is like this. All of his review comments are about clever ways to reduce the code size, but are usually slower and harder to read algorithmically, and half of his tickets we need to lay out the pattern step by step instead of letting him just do it because he apparently has some kind of mental block with understanding object oriented design, everything is procedural.
106
u/SaylorMan1496 May 08 '23
Short variable names should be shunned, the namespace shortening is ok but the variable shortening hurts my eyes
2
u/Vitamoon_ May 09 '23
How do you make a snippet like that?
41
u/iNeedOneMoreAquarium May 09 '23
My brain doesn't have enough working memory to keep track of what everything is doing with those variable names...
33
u/pycvalade May 09 '23
It seems like everyone goes through this phase of trying to make everything a cryptic one-liner. Then a few months pass and you have to debug your own code and hate yourself.
20
u/MurdoMaclachlan public boolean isInt(int i) { return true; } May 08 '23
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
10
u/elektrospecter May 09 '23
Since when did 15 become a magic number
6
u/Cybasura May 09 '23
Damn, this is as bad as ASSEMBLY without comments
5
u/Aphrontic_Alchemist May 09 '23
So what does it do?
2
u/Throwawaytravis May 09 '23
It’s one of those code snippets where I immediately avert my eyes to avoid getting a fucking migraine.
2
u/Anngler May 09 '23
What font is that?
2
u/Kilobyte22 May 09 '23
If you need to write code this dense, comments are nice.
I've seen code which has like 10 really complex lines (massively optimized for performance) interspersed with about 300 lines of comment :D
Admittedly that was very low level SIMD code.
1
u/Marthurio May 12 '23
Such variable names should be illegal.