juan_gandhi: (Default)
[personal profile] juan_gandhi
 So, if you think you call a function in your code, and this function returns current time, or a random number... IT'S NOT A FUNCTION. Your code is function of "random number", or "time".

So, if your code is written as something that retrieves this kind of data, to test your code, you should provide that data. Not just today, but try the time, like 10 years from now. As to "random", You provide the randomness. If your code cannot be fixed to behave as a function of those inputs, make your "random stream" or "time stream" not hard-coded, but substitutable. Mockable. And mock it in your tests. MAKE SURE that you don't provide just happy-path data. Provide anything. A sequence of 100 numbers 4 for random. Time that is 10 years from now. Or even 30 yeas from now.

Make sure that your tests don't depend on anything. Because test Must Be Reproducible.

All these things, I know, are obvious to some, and not obvious to others.

If you still have questions, ask. But don't argue. Because what I say is math. Unless you have another math (some people do), or another logic (there's plenty of them), please don't argue.

I'd be glad to see how all this changes if logic is e.g. linear. 

 

How to test nondeterministic functions

Date: 2020-08-24 05:52 pm (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
> if you think you call a function in your code, and this function returns current time, or a random number... IT'S NOT A FUNCTION.

What you describe as "FUNCTION", is usually called "deterministic function".
~~~~~~~~~~
https://www.google.com/search?q=deterministic+function
Deterministic functions always return the same result any time they are called with a specific set of input values and given the same state of the database.
~~~~~~~~~~
Why did you chose using non-standard "function" label for "deterministic function" concept?

> So, if your code is written as something that retrieves this kind of data, to test your code, you should provide that data.

Not necessarily.
It depends on what exactly we are testing.
For example, if it is sufficient for us to test that nondeterministic function output contains specific phrase that does not depend on random input -- why should we provide random data to that test?

> Make sure that your tests don't depend on anything.

Test that does not depend on anything - does not test production code.
Do you use non-standard definition of word "anything" or phrase "don't depend"?

Edited Date: 2020-08-24 05:54 pm (UTC)

Re: How to test nondeterministic functions

Date: 2020-08-24 09:39 pm (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
What are the signs that these people are clueless about what function is?

"Idiots" sign

Date: 2020-08-24 11:24 pm (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
If I do not understand your answer -- this is a sign about you and me, not about other people.

Re: "Idiots" sign

Date: 2020-08-24 11:49 pm (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
> Whom here do you understand, name one.

I understand almost everyone, including you.
It is your [incorrect] opinion that I do not understand you.
But most of the time I do understand. I just do not always agree.
Or, sometimes, I misunderstand. But, most of the time, I understand correctly.
Edited Date: 2020-08-24 11:52 pm (UTC)

Sings of understanding

Date: 2020-08-25 03:24 pm (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
Why do you think that I do not understand almost everyone [who I choose to carefully read]?

Re: Sings of understanding

From: [personal profile] dennisgorelik - Date: 2020-08-25 05:13 pm (UTC) - Expand

The book

From: [personal profile] dennisgorelik - Date: 2020-08-25 05:38 pm (UTC) - Expand

Re: The book

From: [personal profile] dennisgorelik - Date: 2020-08-25 06:47 pm (UTC) - Expand

Re: The book

From: [personal profile] dennisgorelik - Date: 2020-08-25 07:17 pm (UTC) - Expand

Re: How to test nondeterministic functions

Date: 2020-08-25 07:20 am (UTC)
From: [personal profile] sassa_nf
If you actually read what the search results are about, you would see it is about SQL specifically. It is no longer "usually". No one outside SQL community uses that term. Even the second best result - google corrected the term to "deterministic algorithm", because google knows people don't know what they are talking about, and what they really mean is algorithm.

Is "nondeterministic function" a useful concept

Date: 2020-08-25 04:01 pm (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
> No one outside SQL community uses that term.

Your observation is incorrect.

https://www.google.com/search?q=%22deterministic+function%22
About 451,000 results

https://www.google.com/search?q=%22deterministic+function%22+-sql
About 524,000 results

Google's search count estimates are a bit weird here, but the main point is that there are plenty of "deterministic function" results with the word "SQL" in it.

> Even the second best result - google corrected the term to "deterministic algorithm"

It looks like you forgot to add quotes around "deterministic algorithm" in your search.
From: [personal profile] sassa_nf
My observation is what I see. Your implication of what I should see has no relevance to the original statement.

But in the end if you understood the substance of what juan gandhi said, bickering about the term is pointless. And if you did not understand the substance, bickering about the term is shallow.
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
> bickering about the term is pointless

I am not "bickering". I have a very specific question.
Such as -- why use more ambiguous term "function" instead of more specific and very searchable "deterministic function"?
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
> Math uses terms.

True, but irrelevant to discussion about testing in programming.

> What people on the internets say, does not matter.

That is incorrect.
What people say on the internets -- matter, at least, to some degree.

> Your opinion, e.g., does not matter. My neither.

These are also incorrect statements.
Our opinions do matter.
From: [personal profile] sassa_nf
Having a specific question does not make it not bickering.

I would rather you answered whether you understood the substance of the post.

If I cared.
Edited Date: 2020-08-25 07:12 pm (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
> Having a specific question does not make it not bickering.

If that specific question help to clarify the opponent's position -- then it is not bickering.

> whether you understood the substance of the post

What post?
From: [personal profile] sassa_nf
The summary of this thread: you started with "you [OP] said X, but the correct thing to say is Y"; then you accused me of using wrong search and offered to do a different search (again a variation on "you said X, but the correct thing to say is Y"), whereas I only described what can be seen when clicking the search URL you posted; now you are weaseling some more shrugging the shoulders in bewilderment.

It doesn't look like you have anything of substance to say.

Usage of term "deterministic function"

Date: 2020-08-26 01:04 pm (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
> I only described what can be seen when clicking the search URL you posted

Are you implying that you did not write "No one outside SQL community uses that term."?
From: [personal profile] sassa_nf
I am not implying, I am plain telling you that you haven't even read what you've found - nevermind what I've found, or could have found.

But then who would expect an admission that yes, the term appears to be SQL-only and doesn't really cut it as a serious objection to the use of a certain well-established term. Diversion is so much easier to play.
Edited Date: 2020-08-26 01:23 pm (UTC)

Misunderstanding question

Date: 2020-08-26 02:48 pm (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)
From: [personal profile] dennisgorelik
>> Are you implying that you did not write "No one outside SQL community uses that term."?

> I am not implying, I am plain telling you that you haven't even read what you've found

You did not really answer my question here.
I asked you about "No one outside SQL community uses that term" statement, not about me reading or finding something.

Did you misunderstand my question or did you pretend to misunderstand it?

> Diversion is so much easier to play.

Is that what you are doing? Diversion?

Re: "то есть" trick

Date: 2020-08-26 03:45 pm (UTC)
From: [personal profile] sassa_nf
> Did you ... or did you ...?

I am not inclined to answer your questions because you are not inclined to answer mine. Although by saying this I've just answered one of yours.

> Is that what you are doing?

This is a "то есть" trick of yours, so the best I can do is ignore.

Expecting answers to unasked questions

From: [personal profile] dennisgorelik - Date: 2020-08-26 06:09 pm (UTC) - Expand

Re: Expecting answers to unasked questions

From: [personal profile] sassa_nf - Date: 2020-08-27 06:10 am (UTC) - Expand

Re: Expecting answers to unasked questions

From: [personal profile] dennisgorelik - Date: 2020-08-27 04:59 pm (UTC) - Expand

Re: "то есть" trick

From: [personal profile] dennisgorelik - Date: 2020-08-26 06:16 pm (UTC) - Expand

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

May 2025

S M T W T F S
    1 2 3
456 7 8 9 10
11 121314151617
181920 21 222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 23rd, 2025 12:11 pm
Powered by Dreamwidth Studios