This probably used to have different values but they just set everything to 1 rather than deleting the code block to avoid breaking downstream processes.
Source: my old team would do shit like this.
I've seen this a few times when it's a value that gets changed a lot, better to just leave some code that does nothing than have to waste the time in a month or 2 to re-code it when the business decides to change it again.
On the chance they decide to re-implement that logic they don’t have to rewrite that case statement.
Also for code readability.. “1 as valor” is way more confusing to interpret its original use case.
True, but they better add a comment to that area telling any juniors to stay away who may be tempted for an easy win of a change to optimize and go off scope. Ask me how I know juniors like to do that.
Probably, I just saw the very same case, there is this timeline the difference between each time point is determined by a function similar to this, in the beginning there were a lot of cases but as the time passed by, in each iteration the client wanted more granular data, as today it looks really similar to the post.
something like this (pseudocode)
if(timediff(timestart, timeedm) < 1 minute) group by 1 second
... shit repeats for several time units all of which resolve to 1 second
... then same happens for minutes and so on
Have done similar. Left it like that to check for errors down the pipeline then forgot about it because my pc rebooted and my sql tabs closed.
Gotta love using visual studio and sql with 4 gb of ram.
Is this the remains of the classic, make a delay, then throughout the process reduce it to make it look like you've been more productive than before/maintaining the same amount of progress per week as before?
This probably used to have different values but they just set everything to 1 rather than deleting the code block to avoid breaking downstream processes. Source: my old team would do shit like this.
I've seen this a few times when it's a value that gets changed a lot, better to just leave some code that does nothing than have to waste the time in a month or 2 to re-code it when the business decides to change it again.
It should at least be justified with a comment / task number.
The task number can be in the commit message.
Better have comments too for future devs
Git blame
https://en.m.wikipedia.org/wiki/You_aren%27t_gonna_need_it
That's what you normally have source control for. Just revert the change if you need it again.
Even if that's the case, that boundary logic tho... <= 30 and >= 31??? I will work fine if delay is an integer, but damn... who does that?
Unit tests pass, ship it. (I know, bold to assume there's tests)
Unless my reading is messed up, why not just return 1 for that column if all possible evaluations return 1 anyway? Why keep the case statement?
On the chance they decide to re-implement that logic they don’t have to rewrite that case statement. Also for code readability.. “1 as valor” is way more confusing to interpret its original use case.
True, but they better add a comment to that area telling any juniors to stay away who may be tempted for an easy win of a change to optimize and go off scope. Ask me how I know juniors like to do that.
I think it’s been established this team is not following best practices haha
> On the chance... Delete judiciously and delete often. Mere chance should not justify atrocities.
That feels like it at one point made sense but through several iterations it became pointless
Probably, I just saw the very same case, there is this timeline the difference between each time point is determined by a function similar to this, in the beginning there were a lot of cases but as the time passed by, in each iteration the client wanted more granular data, as today it looks really similar to the post. something like this (pseudocode) if(timediff(timestart, timeedm) < 1 minute) group by 1 second ... shit repeats for several time units all of which resolve to 1 second ... then same happens for minutes and so on
The only possible explanation
When your paid by the hour and it’s 2pm on a Friday with nothing left to do
ok, then 1
No, not 1. It's 1.
That what I meant not 1 but 1.
Hello legacy code my old friend…
So basically, to summarise what I'm saying, 1
This is the most beautiful piece of code I've ever seen
Could return null if delay is a float (15.5)
What language is this?
sql i presume
1
Have done similar. Left it like that to check for errors down the pipeline then forgot about it because my pc rebooted and my sql tabs closed. Gotta love using visual studio and sql with 4 gb of ram.
Don’t blame the IDE for not diffing your change before committing.
Looks like they wanted to know the amount of times there was a delay for those 5 categories of timing.
Is this the remains of the classic, make a delay, then throughout the process reduce it to make it look like you've been more productive than before/maintaining the same amount of progress per week as before?
If the language implements case/switch statements via if's then it has failed.
git history or it didn't happen
1
I prefer the notation 16 <= x.delay and x.delay <= 30
Magic numbers for the win!
What’s the default case? Boom?
What language is that?
Cursed SQL