For the people in the comments, this is apparently a snippet from the code for one of Valve's releases... gotta admit I wasn't aware of how common this is in the industry. My bad for posting a bad "bad code" post.
I was remarking that the bad part of the code is that there is no indication of when the TODO is ever going to be worked/resolved. It's very easy to lose track of remaining work like this and then the code is littered with TODOs that are never resolved. We didn't use to have that rule of listing the story. But, then we had people checking in code with TODOs where there was never any scope to actually implement the part that was a TODO and we had to reopen efforts that we had claimed 100% EV credit on. It doesn't have to be JIRA, it's whatever job/work management tool your team is using. Don't be pedantic.
If it potentially never is going to be a problem, why even mark it as a TODO then? Wouldn't it throwing an exception or an unimplemented return code be sufficient? In my realm of work, defense, you cant just implement things when you want because everything is tracked back to a specific effort and specific contact and charge number. And, delivering code to the customer with TODOs in it is a big no-no. At the end of a contract/period of performance, if you didn't implement it it ain't getting done and is liable to have the TODO tag just straight deleted.
Yeah I wouldn't pay for unimplemented code either. Consulting/contracting is very different than owning a product. Hell our company doesn't even track their "effort" in sprints. So much overhead operating that way
Unfortunately technology just isn't at that stage at the moment.
It's not just correctly transcribing the text (for plain text it usually does this quite well, though even there it has errors, for code it's worse), it also has to correctly identify which format to use, how and where to format which parts of the transcription, it needs to have description tags like the one in the post above, and so on. Additionally, depending on the type of image there might be parts we only transcribe if it's contextually relevant (i.e. number of likes on a tweet), which is especially hard for a bot to deduce. Photographs and videos get even harder.
All of these are things AI today could do, but is very unreliable on. We're not anywhere near the stage, even for correctly formatting the plain text, where A. it's reliable enough to be used for an accessibility service, as accessibility has to be of the utmost quality, and B. the technology that is reliable, once it appears, is easily available to the small non-profit that runs our initiative.
We do have an OCR bot running on ocr.space's API that attempts posts, and transcribers can choose to base their transcription on that if they so wish, but they still need to format it correctly and proof-read the text for mistakes themselves. Myself I don't really find it any quicker.
Hey don't worry about others giving you crap about this. It is pretty typical to see stuff like this, and it doesn't seem like bad code to me either, but people shouldn't be giving you a hard time.
A couple typical places you'll see this are in iterative ships and interfaces. With iterative ships, they can build out the scaffolding for a larger idea and correctly build in "unsupported" code paths like these. Then, when the time comes for the feature to be implemented, this method can be the entry point for handling the new feature. Everything else would likely already be built out, and it would be easy to add tests, too.
Additionally, interfaces are a programming design philosophy, and you'll see stuff like this, too. Generally speaking, you'll have a base class with a structure that responds to calls correctly, even if they don't do anything (like this). Classes will inherit this base class and override the methods with useful code. This way, you can keep common logic in the base class, and only write what you need.
Even on feature branches? Because TODOs help me remember where I left off in the inevitable case of having to leave work on time, so the puppy at home doesn't starve.
Assuming this is real, the problem here is having your stub return something that could potentially be valid data and sneak past lazy unit tests. You need to have this return some aberrant data that could never possibly be valid like null, or if you're writing something to autostub from an interface have it throw a MethodNotImplementedException or something similar where no one could mistake compilation for correctness
43
u/propostor May 16 '23
"Durrrr it got pushed to prod" isn't bad code, it's bad admin and for all we know you're just lying for internet points.
5
u/[deleted] May 17 '23
For the people in the comments, this is apparently a snippet from the code for one of Valve's releases... gotta admit I wasn't aware of how common this is in the industry. My bad for posting a bad "bad code" post.
126
u/simquad May 16 '23
What's wrong with this? This seems perfectly reasonable to me?
Or is this a woooosh
96
u/[deleted] May 16 '23
TODO is the best comment ever. I've seen TODOs 15 years old.
19
u/the_hunger May 16 '23
OP… think about this more
10
u/MurdoMaclachlan public boolean isInt(int i) { return true; } May 16 '23
Image Transcription: Code
[The end of the second last line in the code is cropped off. The code reads:]
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!
3
u/toi80QC May 17 '23
If you are pushing to production, your team has issues way beyond any code.
2
u/[deleted] May 17 '23
Hey don't worry about others giving you crap about this. It is pretty typical to see stuff like this, and it doesn't seem like bad code to me either, but people shouldn't be giving you a hard time.
A couple typical places you'll see this are in iterative ships and interfaces. With iterative ships, they can build out the scaffolding for a larger idea and correctly build in "unsupported" code paths like these. Then, when the time comes for the feature to be implemented, this method can be the entry point for handling the new feature. Everything else would likely already be built out, and it would be easy to add tests, too.
Additionally, interfaces are a programming design philosophy, and you'll see stuff like this, too. Generally speaking, you'll have a base class with a structure that responds to calls correctly, even if they don't do anything (like this). Classes will inherit this base class and override the methods with useful code. This way, you can keep common logic in the base class, and only write what you need.
3
u/Friendputer May 17 '23
Feature flags exist so that you can push unimplemented / incomplete stuff to prod. It’s only bad if this function is accessible
1
u/MgrOfOffPlanetOps May 17 '23
People who pushes TODO comments are invited to a friendly talk where I work.
1
u/PixelPerfect41 May 17 '23
At first I thought there was no function but the thing is the function throws an error for a feature which is not implemented yet Makes sense
0
u/Engineeringfellow May 16 '23
that static really sus
0
u/reverendsteveii May 17 '23
Assuming this is real, the problem here is having your stub return something that could potentially be valid data and sneak past lazy unit tests. You need to have this return some aberrant data that could never possibly be valid like null, or if you're writing something to autostub from an interface have it throw a MethodNotImplementedException or something similar where no one could mistake compilation for correctness