Questions tagged [functions]
Function is a block of code which performs a specific task.
326 questions
7 votes
8 answers
942 views
Why is "one function do more than one thing" a disadvantage of "boolean parameter", but not in "polymorphism"?
According to Is it wrong to use a boolean parameter to determine behavior?, I know using boolean parameters to decide the behaviour is bad, for example, when using boolean parameters as the following: ...
9 votes
7 answers
3k views
If the sleep time of a function at first time differs from the second time, but the output is the same, is it still a idempotent function?
For example, if the sleep time of a function would change after first execution but the output remains unchanged, e.g.: public static int myFunction(){ try { Thread.sleep(MyClass....
17 votes
8 answers
5k views
When should a function be given an argument vs getting the data itself?
When is it better to pass data to a function in a parameter, and when is it better for the function to just fetch the data itself? Here's some simplified examples in PowerShell: Option 1 (give the ...
6 votes
4 answers
3k views
How do you honour the principle to only do "one thing" in a method in reactive streams?
Uncle Bob mentions in his book "Clean Code" that "[f]unctions should do one thing [...] only" and advocates that a method should stick to one abstraction level (I'd call it flight ...
0 votes
1 answer
595 views
How do function inlining and Tail Call Optimization affect call stack?
I've just accidentally came across this answer about inlined functions and I'd like to know how this affects call stack. But I can't add comments because I don't have enough rep so I decided to ask ...
0 votes
0 answers
325 views
C# Azure Function Durable Function Vs Batch Timer Trigger Function
I have a question related to the best approach when resources are limited, such as on the Azure Function consumption plan. I have an IoT device, and the number of IoT devices is likely to increase to ...
0 votes
0 answers
149 views
Python Typechecking versus TypedDicts?
From what I understand from this answer, it is not possible to use a typeddict and typechecking in a function. So for example, if one has a function: def some_func(some_int: int, some_dict:...
2 votes
2 answers
263 views
Should I abstract function calls with duplicate arguments?
I have an intuition, that I'd like to read what others have talked about. To me, it seems fairly intuitive that when you have a function which is called multiple times with the same arguments, it ...