Skip to main content

New answers tagged

0 votes

Name of technique for inferring type arguments of a type parameter?

You might be looking for forward and backward inference. Try searching https://github.com/google/closure-compiler for these terms, in particular check out TypeInference.java: /** * We only do ...
Ardeco's user avatar
  • 1
1 vote

When should a function be given an argument vs getting the data itself?

It is a good practice to separate your core/business logic from IO, parsing, serializing, deserializing and other technical staffs. Then you can write unit tests against the core logic only and verify ...
Gulshan's user avatar
  • 9,462
1 vote

What is the common procedure used when compilers statically type check "complex" expressions?

I wish I'd found this conversation earlier! By the time I found this I had mostly worked it all out for myself, but it had taken me some time to get here. A few years ago I stared a project to write ...
Graham Toal's user avatar
0 votes

When should a function be given an argument vs getting the data itself?

From "The Clean Code": Statements in a function should be the same level of abstraction If you follow this rules, your functions will either be functions that do one low-level thing or ...
Falco's user avatar
  • 1,301
0 votes

When should a function be given an argument vs getting the data itself?

If performance is not a concern, which sure is not in 99 percent of cases, then you should just strive for writing maintainable code. There is, I dare to say, only one rule to follow when writing ...
Atif's user avatar
  • 163
2 votes

When should a function be given an argument vs getting the data itself?

The problem with simplified examples is that, being simple and straightforward, they don't press against the relevant sensory and cognitive limitations that we're trying to deal with by folding things ...
Steve's user avatar
  • 9,202
-1 votes

When should a function be given an argument vs getting the data itself?

There are plenty of situations where the called function cannot know certain data. Let’s say I have a function returning my income tax. The tax depends on my circumstances and my income. So you think ...
gnasher729's user avatar
2 votes

When should a function be given an argument vs getting the data itself?

There can be a lot of reasons to chose the one or the other. The main drivers are: Separation of concerns: When the function gets the data itself, it constraints itself to one single way of getting ...
Christophe's user avatar
  • 78.6k
42 votes
Accepted

When should a function be given an argument vs getting the data itself?

When should a function be given an argument vs getting the data itself? When it has a job besides getting the data. I can see why you'd be confused about this. None of your functions are named after ...
candied_orange's user avatar
10 votes

When should a function be given an argument vs getting the data itself?

As usual, there are various influences on whether to do one or the other. Is it likely that you will at some point have to do the same processing on different data (or some other processing on the ...
Kilian Foth's user avatar

Top 50 recent answers are included