12
votes
Proving program correctness under all possible cases
Ensuring correctness of a computation mathematically is quite possible, just enormously expensive. Basically, you have to set down the requirements in a formal semantic system that is as rigid as a ...
5
votes
Accepted
Single code fragment to perform two different operations
What you are describing sounds like you want something similar to the relationship between a DateTime and a TimeSpan. Perhaps you could describe it as a Note and a NoteShift. I think that calling it ...
4
votes
Proving program correctness under all possible cases
First you have to know what a "bug" is. In some projects this might be rigorously defined, in other projects it might be "I do not like the color". And opinions will differ about ...
4
votes
Java - Does extending a class which itself extends a class which itself... and so on... is healthy..?
To answer your questions directly:
1) No, it will not affect performance much. Generics are mostly erased by the time the program gets executed anyway, so the additional cost is really only multiple (...
3
votes
Alternative To Generic Methods where Type is known at runtime
Curry generics
Since you don't want to use reflection to call generic methods, I'll give you an alternative: Curry the generic parameter. I hope that makes sense.
To handle operations that depend on ...
3
votes
Differences between streams and iterators in C++?
I hope it's not poor form to answer my own question, but upon trying to implement a LogicProgramAnswersetIterator, I ran into some problems that lead me to think either I would have to go to "heroic" ...
3
votes
Differences between streams and iterators in C++?
Take a look at the documentation - specifically the category table and the stream iterators section.
The stream iterators all belong to the InputIterator or OutputIterator categories (only the first ...
3
votes
Proving program correctness under all possible cases
It seems noone here answered your literal question:
Is it possible to know all possible defects in a program before I write a single line of code
For this question, the answer is trivial: it is ...
2
votes
General Excel Processor and Validator
Most extract-transform-load operations cannot be made generic. Generalizing something means finding an abstraction that works in all use cases, and as you've found, when the business rules are ...
2
votes
I've a doubt regarding Environment Model of execution
Yes, the concept of an “environment” is a language independent concept. The term is used frequently in programming language theory, though “bindings” is more generic: names are “bound to” something, ...
2
votes
How should I provide generic typing and allocation for a collection library in C?
How should I provide generic typing and allocation for a collection library ... ?
Establish boundaries
Without scope limits, this task will evolve into a re-creation of C++. Assuming that is not the ...
1
vote
Single code fragment to perform two different operations
The most elegant way to do this is to represent an OctiveNote as an integer. This is in swift but it should be easy to translate:
enum Note: Int {
case c, d, e, f, g, a, b
}
struct OctiveNote {
...
1
vote
Alternative To Generic Methods where Type is known at runtime
Classes that implement IEnumerable<T> also implement the non-generic interface IEnumerable, so you can just use that.
Change this:
private async Task<Ienumerable<?>> ...
1
vote
Accepted
Templates for generic code and code flexibility
This is part of why most of the standard library deals in iterators rather than dealing directly with containers themselves. Iterators were designed from the beginning to support iteration over the ...
1
vote
Adjective for function types on wether the values are received or sent
The set of valid inputs to a mathematical function is the domain, and the valid outputs the codomain or range. These should more or less equate to the values contrained by the types of your sent/...
1
vote
Accepted
Definition of Generic function
There are several meanings to "generic".
Informal definition
"generic" in everyday language something that shares common properties but is less specific in some ways.
Under this perspective, ...
1
vote
Accepted
Wrapping Controller / ApiController to remove boilerplates
Its fairly common to use a custom BaseController from which your other controllers inherit rather than Controller. I dont think there is any particular danger here.
However! I have to agree that its ...
1
vote
Wrapping Controller / ApiController to remove boilerplates
You are doing it wrong. Your approach simply violates the Interface Segregation Principle which says
No client should be forced to depend on methods it does not use
Imagine if I have a controller ...
1
vote
Accepted
What is the reason behing Tuples instead of HList in akka-http
On https://gitter.im/akka/dev, Konrad Malawski writes:
It's about
the horrible error messages that one gets if things go wrong with HLists
not depending on shapeless, so people can use ...
1
vote
Java - Does extending a class which itself extends a class which itself... and so on... is healthy..?
If it is a little confusing to you, it's a problem. Someone unfamiliar to the code (which will probably be you in 2 months) will be utterly baffled.
From the look of your code, you are letting ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
generic-programming × 27c# × 9
generics × 6
c++ × 5
java × 4
c × 4
design × 3
object-oriented × 2
programming-practices × 2
programming-languages × 2
inheritance × 2
templates × 2
stl × 2
design-patterns × 1
algorithms × 1
python × 1
database-design × 1
api-design × 1
data-structures × 1
sql × 1
refactoring × 1
asp.net × 1
dependency-injection × 1
libraries × 1
patterns-and-practices × 1