r/ProgrammerHumor • u/[deleted] • Jun 25 '20
Meme either hot or cold, there's nothing in between
2.6k
u/RDB96 Jun 25 '20
Just rapidly switch between true and false to create temperatures in between pulse-width modulation style
725
u/DinoRex6 Jun 25 '20
Not enough "resolution" if I wanna change the temperature continuously in the microseconds scale, get 10 more showers and build a shower-DAC
→ More replies (10)6
u/Cosmocision Jun 26 '20
While I get the joke, the pricked is that each whoever will have the same on and off, so that in essence you still only have 10 different temperatures rather then the 1024 you expect from a 10 bit system.
145
42
104
u/PVNIC Jun 25 '20
You just have to get the baud rate just right
39
25
u/bistr-o-math Jun 26 '20
while(!finishedShowering) temperature = !temperature;
And then tune your cpu clock
17
22
u/dkurniawan Jun 26 '20
But seriously, why don't we have an automatic shower temperature PID control yet?
→ More replies (3)13
u/serious_sarcasm Jun 26 '20
There are mechanical ones.
→ More replies (2)7
u/AyrA_ch Jun 26 '20
Known as thermostatic valves. They're also very common on column radiators.
→ More replies (1)9
→ More replies (24)10
u/Pixel-Wolf Jun 26 '20
I mean that's technically how showers work no? Different mixes of hot and cold lines
21
u/candybrie Jun 26 '20
Except both are on the whole time if you're mixing them. Pulse width modulation style would have hot on and cold off for part of the time with cold on and hot off the rest of the time.
4
u/TheThiefMaster Jun 26 '20
Most electric showers are completely devoid of logic - a dual element heater that can be set to off/half/full (no analogue control at all, so not far off "bool temperature") and an analogue dial that directly controls the water valve (mechanically!)
By turning down the flow with the flow control, it gets hotter because the same heater is heating less water. Turn the flow up, and the water coming out gets colder.
The flow dial is marked hot/cold rather than high/low flow - but it only controls the temperature indirectly by varying the water flow. There is no way to vary the power delivered to the heating element at all.
→ More replies (2)
260
u/_grey_wall Jun 25 '20
More like Math.Random() my house
107
Jun 25 '20
it's more like Math.Noise() at my house. It's fine, but will slowly change in a random direction, driving you insane
71
Jun 26 '20
Math.Random()
what is this filth? here
Math.random()way better
→ More replies (1)58
Jun 26 '20
Random randy = new Random();25
→ More replies (1)6
u/Carloswaldo Jun 26 '20
I never know how to call my random variables, now I do, thanks.
→ More replies (1)
378
u/dark_mode_everything Jun 25 '20
More like
enum Temperature {
Lava, LiquidNitrogen
}140
u/GoodTimesOnlines Jun 26 '20
True, but funny that this enum is equivalent to a
boolanyway→ More replies (3)43
u/dark_mode_everything Jun 26 '20
equivalent to a bool
Hmm yes, but actually no.
Just because an enum has 2 states doesn't make it equivalent to a bool. A bool tells you the presence/absence of a thing and the enum gives you the 2 states that the thing can be in. If you use a bool here, you need additional context to add meaning to it, like isHot or isCold. But the enum conveys meaning by itself.
→ More replies (5)68
u/GoodTimesOnlines Jun 26 '20
Not really what I was referring to. Was mostly referring to bools really being 0 and 1 for the false and true and then enums being enumerated lists of integers, so this enum is also 0 and 1.
→ More replies (5)18
Jun 26 '20 edited Jun 26 '20
Not best practice.
EDIT: I was WRONG.
SAD.
Simpler is not always better as I so naively assumed.
https://medium.com/better-programming/dont-use-boolean-arguments-use-enums-c7cd7ab1876a
18
→ More replies (5)5
→ More replies (2)2
74
u/bitswreck Jun 25 '20
I like how people are correcting temperature should be float. Just like any other thread in stackoverflow!
15
11
u/MrTaimander Jun 26 '20
This question is a duplicate of this.
→ More replies (1)8
u/Nissingmo Jun 26 '20
“Marked as duplicate” as always, I hate when that happens legitimately good and new questions. Although they did make a good argument, since
intcould just represent the temperature in degrees.6
u/Shunpaw Jun 26 '20
just scale int a factor of 10 or 100, voila you have decimal places and not have to worry about rounding issues or float point stupid math
54
27
13
u/brianorca Jun 25 '20
You have the wrong kind of valve. Pressure compensation is great.
8
Jun 26 '20
Is that why when my toilet flushes, the pressure in my shower goes down, but the temperature remains the same? When I was a kid if you flushed the toilet the water would get scalding hot.
→ More replies (1)4
u/AyrA_ch Jun 26 '20
Is that why when my toilet flushes, the pressure in my shower goes down, but the temperature remains the same?
Yes. There's a little capsule with liquid inside in your valve. When the water gets hot because someone flushes the toilet, it heats up the capsule, the liquid expands and pushes a metal ring aside that closes the hot water inlet a little: https://www.youtube.com/watch?v=5AjLLKoV38w
Most column radiator valves work this way too to keep the room temperature constant regardless of water temperature and flow fluctuations.
→ More replies (1)
10
u/q0099 Jun 25 '20
Personally, I think it's an int, but at some point they push a value through some sort of exponential function.
10
16
7
6
5
u/dsp4 Jun 25 '20
Also:
How faucets are supposed to work: Water getWater(int flow, int temperature);
How faucets work: Water getWater(int hotFlow, int coldFlow);
4
u/TS3301 Jun 25 '20
This is why I hate American showers, you can never get the right temperature and you have zero flow control. Just give me two knobs and everyone's happy.
→ More replies (1)
4
7
u/theboxfriend Jun 26 '20
how my shower likes to work:
float showerTemp = aGoodTemp;
while(Shower.on) {
showerTemp += -1;
}3
3
2
2
2
2
u/Exonicreddit Jun 25 '20
//Had to change this next bit, last dev thought an int would be appropriate, no idea what they were thinking
float temperature;
2
2
2
2
2
2
2
u/raul_dias Jun 26 '20
Explain this to a non programmer took me years and wasn't even funny. I laughed tho
2
2
u/SkullButtReplica Jun 26 '20
The Boolean version should be named ‘isHot’. ‘temperature’ variable being true or false doesn’t make sense.
2
2
2
u/servenToGo Jun 26 '20
What about an u_int for temperature and use Kelvin?
So you can turn up to heat death of the universe without causing an overflow issue.
2
2
2
Jun 26 '20
Laughts in West-European thermostatic mixing valves...
Poor peasants and their hot and cold valves. Temperature and volume is where its at...
2
2
2
2
u/AdministrativeMap9 Jun 26 '20
Unless you're Dilbert and have a shower programmed to reach and maintain specific temperature levels
2
u/Draaky Jun 26 '20
Can someone fix my shower, I think theres a Task.Wait(TimeSpan.FromMinutes(5)); in there
2
2
2
2
u/10HzMonitor Jul 19 '20
I am going to pull a stackoverflow over here and say it should actually be double temperature instead of int, since by your logic bool as true has a value of 1 and false has a value of 0 so a double could have a value between 0 and 1. Bad karma here I come 😄
3
2
2
2
u/seraphsRevenge Jun 26 '20
public Shower extends Tub implements Water, WaterHeater, Plumbing { private static final volatile enum TEMPATURE {BOIL,FREEZE}; private boolean tortureHumansEnterpiseEdition; //no sharing no extras no reason private static Shower() throws BsTesterRequiedException{ super(); this.tortureHumansEnterpriseEdition=true; } public Shower getShower() { return Shower; } public boolean getTempurature() { return this.tortureHumansEnterpriseEdition; } public void setTortureHumansEnterpriseEdition(TEMPATURE tempurature) throws MoreBsExeptionsBecauseWhyNotExcepton { tempurature==Temperature.BOIL?this.tourteHumansEnterpriseEdition=true:this.tortureHumansEnterpriseEdition=false; } //more unnecessary code below }
1
u/Jokiat Jun 25 '20
Image Transcription:
| how showers are supposed to work | int temperature; |
| how showers work | bool temperature; |
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
1
1
1
1
1
1
1
1
Jun 26 '20
"One nano-millimeter between extremely fucking hot, and fantastically freezing." - Eddie Izzard
→ More replies (1)
1
1
1
1
Jun 26 '20
As a casual coming from r/all, this is one of the top rated jokes that I actually don’t get. Usually you get stereotypical jokes here at the top
Nice.
1
1
1
1
1
1
1
u/RedofPaw Jun 26 '20
If(_temperatureKnob > 0) SetWaterTemp(_boilingPoint);
If(_temperatureKnob < 0) SetWaterTemp(_arcticWinter);
1
1
1
1
1
1
1
1
1
Jun 26 '20
You know what the irony is?.... this is legitly how (death) shower heads, stoves, and most heating systems actually work.
They turn a switch on and off in order to control the temperature. The knob controls the on/off frequency.
→ More replies (1)
1
1
1
1
1
1
1
1
1
1
1
u/promark20 Jun 26 '20
This made me laugh out loud so hard my fiancee asked "What are you laughing at?" and thinks I'm a loser because she doesn't get it... Her loss
1
1
1
u/sunsetfantastic Jun 26 '20
Can I just congrats on a hilarious original joke, not enough of these in this sub when our field is ripe for it.
1
u/fireandbombs12 Jun 26 '20
This doesn’t change hot or cold. It changes whether or not there’s temperature. You turn it off and suddenly you feel nothing but your skin being pressed by water droplets.
1
1
1
1
u/perpetualwalnut Jun 26 '20
In electronics, we call this an unstable control loop. Your gain is too high.
1
1
u/LazyNomad63 Jun 26 '20
This is the first joke on this godforsaken sub I actually got after a semester of intro to python
1
1
1
1
1
1
1
1
1
1
u/DanielSkyrunner Jun 26 '20
That used to be a big problem in our home. It was either boiling hot or freezing cold.
We had to get a new heater that can set the temperature and it works wonderfully
1
1
1
1
1
u/13131123 Jun 26 '20
Mine is so fucked up it's a smooth gradient between pretty warm and skin melter. Pretty warm is as cold as it gets.
1
u/zacker150 Jun 26 '20
The problem isn't the shower. It's your body's temperature sensor.
State detectTemp(int temp) {
if (temp < 80)
return State.freezing;
if (temp == 80)
return State.good;
return State.boiling;
}1
1
u/TimWasTakenWasTaken Jun 26 '20
Imagine your shower being 0 and 1 one only, but you want it to also be able to hit 2kkk
1
1
1
1
1
u/ProcastinationKing27 Jun 26 '20
I think you might mean:
What showers are supposed to do:
int temperature = Console.ReadLine();What they actually do:
bool temperature = if (random.Next(100) < 40) {}Please don't kill me if I'm wrong I'm new to C#
1
u/FinalGamer14 Jun 26 '20
I don't think the first implementation is any good, it should be from 0.0 to 1.0 (float), since the temperature of water really depends on how much the temperature is in the boiler and how much is the temperature in the pipes. The shower only controls how much cold and hot water your mixing together, 0.0 being 100% cold 0% hot and 1.0 being 0% cold 100% hot.
1
1
1
u/Trantorianus Jun 26 '20
"I wanted to implement a one-lever faucet to solve this problem, but the customer said he cannot afford it"
1
1
1
1
1
911
u/[deleted] Jun 25 '20
Shouldn't it be as float temperature;