Definitely not haha. It's a stupid way of doing things. It makes code hard to read with basically no benefits x'). Ideally this code shouldn't even have a switch anyway, because while it's functional, pretty sure a string comparisons for each "state" of the string animation, instead of just a progressing looping integer index, is stupid and would scale terribly, not that it really matters for something that simple. There's a reason I posted this to r/badcode lmao
Completely agree. I try to code in a fairly verbose way (within reason, obviously). It makes my code easier to understand, both by other people on my team, and myself when I look at the code a year later having forgotten entirely what it does.
And this is a special case too, because it's a return that takes a ternary assigning a variable where one of the two outcome is the result of the assignment of another variable lmao
nullable int x = 5;
if (x is not null) {
// x is cast to "int" here, as opposed to "nullable int"
}
Superclass y = ...;
if (y is Subclass) {
// y is cast to Subclass here
}
I'm assuming that's if you want to use temp in the rest of the code? Otherwise I don't see the reason to do the assignment here. If the reason is to use temp in the rest of the code, why not assign it before the if-statement and just doing if(!temp)?
This started as like, a normal but un-optimized way of writing a quick string animation, and for some reason it devolved into a very very unreadable code x')
Scalability doesn't matter. It's 3 dots animating up and down. I don't think I ever saw this sort of animation in anything but three dots. The argument of "could be 5 dots" also sucks because this whole thing is like 5LOC -- if you need to rewrite it whenever you move to more dots, just rewrite it then, it's easy enough.
The solution presented is cute -- not the traditional thing you'd see every day and readable just enough to be entertaining without being difficult to understand. This is the kind of code that makes me happy to code, not the same dry traditional implementations. Whoever wrote this, kudos, you're a fun person!
I agree that it's neat looking, but it's a solution that actually scales terribly. The simplest way to fix it would be reemplacing the last string by an index and switching that instead, which would scale better, while working in a similar fashion ^
147
u/Auxilor Jan 06 '23
not everything has to be a one liner
64
u/PooSham Jan 06 '23
Assignments inside conditions make my blood boil.
17
u/AntheusMG Jan 06 '23
This started as like, a normal but un-optimized way of writing a quick string animation, and for some reason it devolved into a very very unreadable code x')
19
u/pmSexySmilesGirl Jan 07 '23
Controversial opinion:
Scalability doesn't matter. It's 3 dots animating up and down. I don't think I ever saw this sort of animation in anything but three dots. The argument of "could be 5 dots" also sucks because this whole thing is like 5LOC -- if you need to rewrite it whenever you move to more dots, just rewrite it then, it's easy enough.
The solution presented is cute -- not the traditional thing you'd see every day and readable just enough to be entertaining without being difficult to understand. This is the kind of code that makes me happy to code, not the same dry traditional implementations. Whoever wrote this, kudos, you're a fun person!
This is not r/badcode
33
u/No-Witness2349 Jan 06 '23
Transcript:
1
u/[deleted] Jan 07 '23
eh its fine it works.
0
u/[deleted] Jan 07 '23
[deleted] — view deleted comment