Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
So a mistake was made today a few years ago, eh?
I'm just kidding lol
Happy birthday 🤜🏻🤛🏻 -
You mean, years_to_live--;
Because days to live is in days, and -- only subtracts 1.
Happy birthday, in any case. -
duckWit56696y@RememberMe if we're going to be "that guy", --days_to_live; wouldn't work anyway unless you know the exact date you are going to die. Age is known, days to live is *usually* unknown (even if we're talking about years).
Since we aren't computers we understand anyway, though.
Happy Birthday, @Toshib-htr. -
fdgram4866y@duckWit days_to_live could be write-only, as in allow modification but not reading the actual value, e.g. only implementing operator--()
-
duckWit56696y@fdgram I love this technical and nerdy conversation.
Allowing modification of what number, though? Even write-only, that write accessor is modifying a value, which is unknown. It's kind of like an attempt at decrementing a null value. -
fdgram4866y@duckWit the "write accessor" can be part of the class hence having private access to its member variables, meaning the public interface is only able to mutate the value indirectly. You can also imagine some hardware that decreases a number upon receiving a signal, but with no way to read the number back out.
Both of these would have to be initially seeded with values of course. -
fdgram4866y@duckWit as a more practical example you can imagine sending me money, in an envelope, by wire transfer, or otherwise. By doing this you're mutating my amount_of_money without being able to read its actual value.
-
duckWit56696y@fdgram I completely understand a write-only property or method that mutates a private variable. No need to explain that.
What is the initial value of that private member variable? If you are decrementing time to live, it means that it is decrementing from a variable with a set value.
Usually, humans don't know how much time they have left, which is why I made the comparison to the null value.
My code decrements my time to live. Great. What was the old value? What's the new value? I told it to decrement by 1 (the --), but from what to what?
Do you know when you're going to die? -
fdgram4866y@duckWit "What was the old value? What's the new value? I told it to decrement by 1 (the --), but from what to what?"
This makes it obvious that you don't actually understand how a write-only property works.
As I said, the variable would have to be seeded with a value when the object is created or before you try modifying it. There's no need for me to know the value when calling operator-- since it's all contained within the object. -
duckWit56696y@fdgram lol omg
Class A calls ClassB's DecrementDaysToLive();
Let's look at the implementation of ClassB (this is in C# syntax)
public ClassB
{
private int daysToLive;
public ClassB()
{
daysToLive = ??; // 0? 100? 10000? 50000?
}
public void DecrementDaysToLive()
{
--daysToLive;
}
}
....so.
What value does ClassB initialize the variable daysToLive to? Does it know when you are going to die? Programs are literal. My point above is that in order for a program like that to work, it would LITERALLY have to know when you are going to die, otherwise the value of daysToLive only shows how many times you called it, not how many days left you have to live. -
fdgram4866y@duckWit knowing the actual value is out of scope of the "how to mutate a variable without knowing its value" topic. The value could be set by your favourite God; we don't know how the object was created. We just invoke operator-- on it.
-
duckWit56696y@fdgram and there we have it. It's not a literal program (my point the entire time). I was responding, originally, to @RememberMe being "that guy" on somebody's birthday announcement saying that his code doesn't really work/isn't consistent.
To that, I said, well, if we're going to be "that guy", then we might as well say that the code wouldn't work because quite literally the code would have to know when you are going to die, regardless of whether or not it's decrementing days or years.
Enter you, and your educational explanations on encapsulation. -
duckWit56696yAnyway, Happy Birthday again, @Toshib-htr! I hope this has been at least somewhat entertaining for you, haha.
-
duckWit56696yIf anybody reading this thread is a writer, I would LOVE to see this conversation show up in a TV Show like Silicon Valley or something. Somebody says "Hey it's my birthday!" and it spawns off an argument between two software devs about how that birthday code would be non-functional.
-
Kaji22626ySimple answer: TTL is a private property of the object, with no getter function. Any attempts to retrieve it either return NULL or call an estimate_ttl() method that checks all factors known to affect TTL except the TTL itself and provides a (likely inaccurate) guess.
-
fdgram4866y@duckWit our code doesn't have to know what the actual value is. That's the beauty of programming. A proprietary library can provide the value; it doesn't matter at all where the value is coming from when we only care about mutating it. I don't grasp what your problem with this abstraction is.
-
duckWit56696y@fdgram I don't have a problem with the abstraction.
Please read the following to understand my point and not to just craft a reply:
I was originally responding to someone above who took figurative birthday code and turned it literal by making corrections to it. I was pointing out that if we're going to make corrections to figurative birthday code then the whole thing falls apart anyway because the literal, abstracted implementation would have to know when you die to support --daysToLive.
If it's literal, then something has to implement the code that handles the receiving end of the call. Someone has to have written it. What did they initialize that value to? It's write only--got it--but the literal implementation acts on a known value of something that can't be known.
We can keep it figurative like you did and say "God wrote it" and in that case the answer is "God knows how much time you have left", sure.
TL;DR I'm speaking literally, you're speaking figuratively.
Conclusion: let's not get nitpicky about figurative code. Let's keep it figurative.
And Happy Birthdays all around, we've all earned it by now! -
Actually your time to live is not correlated with your age but instead there is an odd correlation with the number od breaths you take. Apparently we all have a maximum amount of breaths before we die of old age.
-
Kaji22626y@Santaclauze
/* Assumes average of 672,768,000 breaths by age 80 */
function every_breath_you_take() {
static $breath_count = rand(0, 900000000);
return $breath_count--;
} -
duckWit56696y@Santaclauze maximum amount of breaths?
So people who exercise regularly with elevated heart rates (and thus, elevated breathing rates) will deplete their breath allotment before someone who spends their whole life in a sedentary state? -
duckWit56696y@Santaclauze I must have been in a bad mood earlier because reading your maximum-amout-of-breaths comment now is hilarious. I completely missed the joke, haha.
-
@duckWit well. Its actually been obsrrved scientifically that sporty people may use more breaths while exercising, their body uses enery more efficiently and they breath less frequently at rest than unhealthy people.
All good for you rage moment ;)
Related Rants
-
agaripian30Got the best cake for my 30th birthday. Only if my wife understood what language I program with. I still love ...
-
GMR51651My girlfriend knows what a coder needs when it’s their birthday. Lucky to have her. Walked into my room and ...
-
Raich11Today my oldest son is 8 years old and with pizza and cake we discussed how to hack his friends tablet, star W...
++years_old;
--days_to_live;
random
birthday