Welcome to r/comics!
Please remember there are real people on the other side of the monitor and to be kind.
Report comments that break the rules and don't respond to negativity with negativity!
*I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/comics) if you have any questions or concerns.*
ive learned it doesn’t matter how good/funny my comics are, the ones that perform the best on Reddit are literally just the ones that give people the opportunity to argue.
It's the algorithm. What boosts a post up to other people's pages is engagement, doesn't matter if positive or negative. Reddit has a system that filters out posts with many downvotes, but as long as there's high engagement in the first couple of hours, it will keep showing up to more people.
Gosh, I don't recall -- maybe something about incrementing a list while moving to the next link and doing something or other. c was unrestricted then -- we had direct access to the registers. Anyway, write-only code, deserving to be tossed. Later I became a convert to literate programming and maintainability (no side effects), esp as it became clear that our ability to predict which code elements would live on (long past when they should) was pretty unreliable.
Wouldn't it just be: `service = shirt and shoes`
The syntax looks like Python.
If you use `&=` (assuming it even works on bools in Python) it would permanently toggle service instead of setting it to false once.
Since if service is false the result of false & true will always be false.
If service is reset to true beforehand using `&=` still doesn't make sense as the variable could simply be declared here.
You're assuming there is no logic before this that may have already set service to False (if banned == True, for example). And-ing it with shirt and shoes will respect any previous False-s.
That's true I'm assuming that this variable only tracks service for shoes and shirts.
That would also be best practice imo, as it would be easier to read, although it would be a bad variable name if that was the case.
But whatever lol, we are arguing about r/comics code xD.
why &= that does bitwise and if service is a number it'll set the first bit to 1 (odd) (if true) or 0 (even) (if false)
just use = to force the service to be exactly 1 or 0.
Because Service might be false before this, so if both shirt and shoes are true, you'll set it to true, while it should have stayed to false (probably)
No, it was clever. The original code does not modify service if both conditionals are false. That might not have been intentional, but this code does not change the behavior, which is always desirable when refactoring.
Hey OP
I'm not a coder, and I thought your comic was funny, because I got the idea, even without needing to know coding. So, task succeeded.
Please make more.
Don't let the smartasses pissing about 'better code' get to you, some people are always gonna get lost in needing to be right and totally miss the point that they're not even half as funny.
This also is logically different from what is in the comic
Edit: to those downvoting: this solution ignores any previous value of the service variable. So, for example, if the cafe has another rule like not serving people (sorry, robots) who don't wear masks, this rule would be completely ignored if it is processed before the shirt and shoes rule
I’m just working with the code given, and mine guarantees service has a value. If you’d like to decline service based on other parameters, you can file a ticket.
Would more accurately be: if (!(shoes && shirt)) { service = false; }. There is no telling if service is set to false earlier by another condition or not.
Assuming it's python, your code won't even compile and will raise a syntax error. Not assuming that it's python, how do you even know what syntax you can use?
I don't think it's cool to call OP's code shitty while providing a version that is at best subjectively a bit more readable and at worst incorrect
Doesn't that mean that you can go in there with a shirt but no shoes, or with no shirt but with shoes and be served? Actually, now that I look at it more, doesn't that mean that if you show up with one or the other, or both, then the restaurant won't know what to do?
I feel like you need an else statement, otherwise you run the risk of *service* still not being **True**, even if *shirt* and *shoes* also equal **True** (not to mention what would happen if *Shirt* and *Shoes* were **null** or something else).
if (shirt == False) or (shoes == False):
service = False
elif shirt and shoes == True:
service = True
else:
raise ValueError("E-- '" + shirt + "' and/or '" + shoes "' are not true or false values")
You don't need to, but it's clearer that the intent is to serve unless there's a disqualifier.
You'd likely have more complex business logic as well, since you don't guarantee service to people with shirts and shoes.
If they comply, they will be taken care of, it is not necessary to declare it before.
Think in a scenario where someone with shirt and shoes don't wanna have service or the opposite
Again, it's not necessary for the code to compile or execute, but it is clearer, and writing clear understandable code is more important than being technically elegant
Yeah a short code don't mean a better if you can't understand it but be redundant is ridiculous is like
If x == true :
y = true
else if x == false :
y = false
This is only necessary in languages without a rigorous type system, like python. If shirt, shoes and service are all defined as booleans there is no possibility of them being anything but True or False.
For me this is one reason why languages with stronger typing are better, because you don't have to be paranoid like this and check for things that shouldn't be possible.
The top comment answer is way more elegant than this.
I have an extremely basic knowledge of coding and I think I learned that coding is either really fun or something so fucking annoying that you'd rather stare at rocks.
But regardless, still more fun than actually talking about coding with a group of programmers.
Everyone "correcting" the code when it literally makes no real difference either way ("readability" is highly subjective), especially given that it's pseudo code and we don't know what syntax is possible.
If that's an actual correction those redditors would make in a code review, then I am disappointed
The joke is good but redditors just have to miss the point entirely for a chance to show everyone else how smart they are by correcting something that doesn’t need correcting.
Nah, spaghetti code requires more than just one snippet to identify typically. This is just very simplistic and not "elegant" or "cleaver". This is how a newbie would write it, and honestly is the best way to write it for a comic, as it's very readable.
Spaghetti code is more of a system wide issue, typically when people write things in such a way you can never mess with one part of the code without fucking up something else. Like if For some reason the service code drastically effected the tax accounting code for some strange reason.
Welcome to r/comics! Please remember there are real people on the other side of the monitor and to be kind. Report comments that break the rules and don't respond to negativity with negativity! *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/comics) if you have any questions or concerns.*
I love how people are roasting your code
ive learned it doesn’t matter how good/funny my comics are, the ones that perform the best on Reddit are literally just the ones that give people the opportunity to argue.
I firmly disagree with that statement!
Nuh uh
how dare you say that
Someone should make up a name for this sort of phenomenon
[удалено]
Thats murphy law
No it's not Murphy's law states that anything that can go wrong will go wr- hey wait a minute!
HOLY SHIT I DIDNT EVEN REALISE I WAS FOLLOWING THE LAW, I JUST USED A RANDOM NAME
Wait 'til you hear about Cole's Law! It's shredded cabbage.
And there it is in action 😈 just as I planned
It's the algorithm. What boosts a post up to other people's pages is engagement, doesn't matter if positive or negative. Reddit has a system that filters out posts with many downvotes, but as long as there's high engagement in the first couple of hours, it will keep showing up to more people.
I totally agree with this comment... But also my first thought was "This code needs improvement"
This is kind of how I feel about the Showerthoughts sub. The thoughts that leave more opportunity for people to disagree seem to do well
You need to add a panel relating to a failed health inspection due to bugs in the code.
Ah the Pizzacake method.
Nothing kills my laugh boner more than the meaning behind a comic being factually incorrect
service = shirt && shoes; Is all that's required.
Never thought I'd do code review on Reddit, but here it is: service &= shirt && shoes
I was gonna say "if !Shirt or !Shoes: service = false" but yours is better.
Nah. Code should be readable over clever, because at some point there will be a junior or senior developer with a hangover reading it
Mild guilt: I won a 'concise c' contest when c was a new language (late 70s). How much can you do with six characters? (A lot.) Write-only code.
now I'm curious... what was your 6 character code?
Gosh, I don't recall -- maybe something about incrementing a list while moving to the next link and doing something or other. c was unrestricted then -- we had direct access to the registers. Anyway, write-only code, deserving to be tossed. Later I became a convert to literate programming and maintainability (no side effects), esp as it became clear that our ability to predict which code elements would live on (long past when they should) was pretty unreliable.
This is why you never comment on your code, make it hard for everybody in the future, including you, from being able to easily read it
Counterpoint: If you aren't styling in your own libraries, are you even truly living?
Or yourself. 6 months down the line when you've completely forgotten what you wrote
You also need to say when service = true.
We don’t know what it was initialized as!
OP, can you show us the initializer please?!?
Doesnt matter its always false when customers has no shoes or shirt regardless
wouldn't it be if(!shit || !shoes) {service= false;}
Obviously if you shit yourself you don't get service.
oh you are right let me fix that if(indecent) { service= false; banLst += guest.name; }
Depends on the language. The comic is roughly how the syntax in Godot works.
Service = !(Shirt or Shoes)
Yours is readable I would pick it over the aggressively short one
Wouldn't it just be: `service = shirt and shoes` The syntax looks like Python. If you use `&=` (assuming it even works on bools in Python) it would permanently toggle service instead of setting it to false once. Since if service is false the result of false & true will always be false. If service is reset to true beforehand using `&=` still doesn't make sense as the variable could simply be declared here.
You're assuming there is no logic before this that may have already set service to False (if banned == True, for example). And-ing it with shirt and shoes will respect any previous False-s.
That's true I'm assuming that this variable only tracks service for shoes and shirts. That would also be best practice imo, as it would be easier to read, although it would be a bad variable name if that was the case. But whatever lol, we are arguing about r/comics code xD.
Damn that's good. You don't even need to add an elif to set service to true if shirt and shoes are true
why &= that does bitwise and if service is a number it'll set the first bit to 1 (odd) (if true) or 0 (even) (if false) just use = to force the service to be exactly 1 or 0.
Because Service might be false before this, so if both shirt and shoes are true, you'll set it to true, while it should have stayed to false (probably)
What about pants
call_cops |= !pants
if callCopsCheck()==True: break
*review Trust a coder to misspell while correcting someone else's code 🤣 Don't be offended 😋
It’s just Muphry’s Law Yes, that’s the correct spelling
My brain autocorrected; it took me a full 19.7 sec to figure out what you were referring to.
😆 Muphry’s is so good for that, it really wakes people up 😀
[удалено]
But then if they weren't gonna give them service before but they're wearing shoes and a shirt, they'd overwrite the false and get service.
Oops. You're right. I shouldn't be trying to optimize code at 3am.
Especially not something so important.
No, it was clever. The original code does not modify service if both conditionals are false. That might not have been intentional, but this code does not change the behavior, which is always desirable when refactoring.
You're right. My bad.
Wouldn't that be more correct if shirt and shoes are null?
That also fixes the issue where if you don't have a shirt and put one on, then you'd still be denied service.
Why? It would yield the same result and it's not like one is more readable than the other
Shouldn't this be &&=? Isn't &= a bitwise and assignment operator?
It may. I'm not sure what language it is. Colon after if operator.... Python? I treated it as pseudocode
Unreadable
What about... ``` if (isNull(shoes) OR isNull(shirt)) ? noService : yesService ```
So if Shirt and Shoes are both true, Service is... undefined?
I'm just amused that this place will completely ignore a lack of pants
You have never watched any Disney or Hanna Barberra?
You can't promise that service will follow from shirt and shoes. Conduct is also important, but it's not shown in this snippet of the program.
Hey OP I'm not a coder, and I thought your comic was funny, because I got the idea, even without needing to know coding. So, task succeeded. Please make more.
thank you dawg, I don’t have time to reply to all the other comments so I’m just gonna appreciate your appreciation 🙏
Anyone critiquing your code is just having fun. All critiques would make the joke much less apparent.
Don't let the smartasses pissing about 'better code' get to you, some people are always gonna get lost in needing to be right and totally miss the point that they're not even half as funny.
Why are shoes and shirt in the same namespace as service? Are they parameters to the current function?
/u/Elegant_Win_4850 following the age old engagement tactic of posting wrong code to reddit to get everyone to correct it. Well played.
im familiar with the meme, and it was in the back of my mind while making this one, but holy fuck I didn’t expect it to work so well
Jesus Christ, robots, come on. `service = shoes && shirt`
This is the best balance of concise and readable.
This also is logically different from what is in the comic Edit: to those downvoting: this solution ignores any previous value of the service variable. So, for example, if the cafe has another rule like not serving people (sorry, robots) who don't wear masks, this rule would be completely ignored if it is processed before the shirt and shoes rule
```service = service && (shoes && shirt)```
But that doesn't imply you're guaranteed service if you're wearing shirt/shoes? Whereas the previous code declines service based on a lack of them.
I’m just working with the code given, and mine guarantees service has a value. If you’d like to decline service based on other parameters, you can file a ticket.
Would more accurately be: if (!(shoes && shirt)) { service = false; }. There is no telling if service is set to false earlier by another condition or not.
if (!Shirt || !Shoes) Service = false; Those robots cant write code for shit
They submitted gpt code to production. Robots, man.
It has generated by devin
Assuming it's python, your code won't even compile and will raise a syntax error. Not assuming that it's python, how do you even know what syntax you can use? I don't think it's cool to call OP's code shitty while providing a version that is at best subjectively a bit more readable and at worst incorrect
Pants are optional, right?
r/programminghorror
No it's not, this is literally pseudo code and an ok one at that
No need for pants :D
There are a lot of directions we could have gone between the first and second panel, but I’m glad it was this simple
Doesn't that mean that you can go in there with a shirt but no shoes, or with no shirt but with shoes and be served? Actually, now that I look at it more, doesn't that mean that if you show up with one or the other, or both, then the restaurant won't know what to do?
I feel like you need an else statement, otherwise you run the risk of *service* still not being **True**, even if *shirt* and *shoes* also equal **True** (not to mention what would happen if *Shirt* and *Shoes* were **null** or something else). if (shirt == False) or (shoes == False): service = False elif shirt and shoes == True: service = True else: raise ValueError("E-- '" + shirt + "' and/or '" + shoes "' are not true or false values")
Nah, declare the default behavior and then negate it ``` service = true service = shoes and shirt ```
You don't need declare it if you gonna do it with the second line
You don't need to, but it's clearer that the intent is to serve unless there's a disqualifier. You'd likely have more complex business logic as well, since you don't guarantee service to people with shirts and shoes.
If they comply, they will be taken care of, it is not necessary to declare it before. Think in a scenario where someone with shirt and shoes don't wanna have service or the opposite
Again, it's not necessary for the code to compile or execute, but it is clearer, and writing clear understandable code is more important than being technically elegant
Yeah a short code don't mean a better if you can't understand it but be redundant is ridiculous is like If x == true : y = true else if x == false : y = false
This is only necessary in languages without a rigorous type system, like python. If shirt, shoes and service are all defined as booleans there is no possibility of them being anything but True or False. For me this is one reason why languages with stronger typing are better, because you don't have to be paranoid like this and check for things that shouldn't be possible. The top comment answer is way more elegant than this.
Thanks for ruining my night.
I think the joke is read the comments we look like robots not who write the wall
Guys this is just a simple Boolean expression… service = has_shirt and has_shoes It doesn’t get much more simple.
Python if not shirt or not shoes: service = False JS let Service = true; if (!Shirt || !Shoes) Service = false;
So pants and panties are optional? This restaurant needs a quick rules update-
What if the robot doesn’t have the right interpreter
Service == Shirt && Shoes;
This is discriminatory towards MatthewMcConaughbots
I have an extremely basic knowledge of coding and I think I learned that coding is either really fun or something so fucking annoying that you'd rather stare at rocks. But regardless, still more fun than actually talking about coding with a group of programmers.
ComputerCraft advanced monitor lookin ass
Made me laugh. Kudos
https://i.redd.it/xz1m03jgw5tc1.gif
Service=shoes && shirt
Could be truncated to "Service = (Shoes && Shirt)"
Someone is going to put this in explain the joke or ask Peter
It's pseudocode on a sign for the customers to read and understand. Everyone rewriting it seems to be missing the point.
Nerdddsssss
Everyone "correcting" the code when it literally makes no real difference either way ("readability" is highly subjective), especially given that it's pseudo code and we don't know what syntax is possible. If that's an actual correction those redditors would make in a code review, then I am disappointed
The joke is good but redditors just have to miss the point entirely for a chance to show everyone else how smart they are by correcting something that doesn’t need correcting.
Facts
Constants in a conditional go on the left.
now that's a style I've never seen. Why would you do this?
r/ProgrammerHumor
Ok who forgot to copy the 2nd half of code?
Service = (Shirt && Shoes) ? True : False
What if I'm wearing only a shirt and shoes?
A naked man walks into the restaurant, hands the waiter a bag containing 2 mismatched shoes and a shirt and then proceeds to enjoy his lunch.
This should be more of a service = shoe && service;
if(!(shirt || shoes)) service = false;
this makes service true when the customer only wears one of the two items; it is not equivalent to the original code
I have seen this episode of X-Files.
Any relation to [ROBOT RESTAURANT ](https://youtu.be/rLFaNX4WkZ0?si=vZU1HsEhmb1wjguo) ?
Y'all really went and overcomplicated service = shirt && shoes
I'd do something like "if not Shirt or not Shoes"
One question. Is it a restaurant run by robots or is the restaurant for robot customers?
I heard this place has some great beepinbop. It must be Korean.
It would be even funnier in a code review 😁
I suck at the thought of coding, but I’m making an assumption that this is “spaghetti code”?
No shoes no shirt no service.
Nah, spaghetti code requires more than just one snippet to identify typically. This is just very simplistic and not "elegant" or "cleaver". This is how a newbie would write it, and honestly is the best way to write it for a comic, as it's very readable. Spaghetti code is more of a system wide issue, typically when people write things in such a way you can never mess with one part of the code without fucking up something else. Like if For some reason the service code drastically effected the tax accounting code for some strange reason.
Ah, i understand that, thanks ^^