Questions tagged [generic-programming]
Generic programming is one method for code reuse. It involves defining a general-purpose data or code structure that can be further specialized to work with concrete types at the location it is used.
27 questions
-1
votes
1
answer
97
views
General Excel Processor and Validator
I've been working on this project where my responsibilities are to code for validating, processing and then dumping into database excel file.
Me and my colleague tried multiple approaches to make it ...
-1
votes
1
answer
147
views
Injecting Adapters Into Client
So I'm building a client for a third API and I want to be able to Get() and GetMany() for each type this controller can provide.
So I've built this adapter, that provides generically typed methods for ...
0
votes
0
answers
55
views
How to map translated variable names for column names, so I can export them?
In short story, I want to make some universal generators for different formats (CSV, XLS, XLSX and JSON for now). Just to be clear, I will make different classes for all formats.
I have different ...
-1
votes
5
answers
600
views
Proving program correctness under all possible cases
There are techniques of proving program correctness under all possible
cases, but that is a more advanced topic, for a later subject in your
curriculum.
I always had this doubt:
Is it possible to ...
0
votes
2
answers
86
views
I've a doubt regarding Environment Model of execution
I came across Environment Diagrams,it is described below
Whenever Python needs to work with an object, that object is stored in
memory; and, additionally, Python also needs a way to associate names
...
4
votes
2
answers
7k
views
Alternative To Generic Methods where Type is known at runtime
I've written a class that synchronizes a table between two databases using Dapper. The public and private Methods in the class are generic and the generic parameter is the POCO class that is being ...
1
vote
1
answer
155
views
Templates for generic code and code flexibility
I have a data which is a std::vector of a "small collection" of items of a given type struct Bunny {};.
I was vague about "small collection" because for now it's a collection of ...
1
vote
2
answers
130
views
Adjective for function types on wether the values are received or sent
I don't know how to phrase this better, but I remember reading an article about type theory, that categorized the values being received by a function and the values being sent back from the functions.
...
0
votes
1
answer
150
views
How should I provide generic typing and allocation for a collection library in C?
I am in the process of implementing a persistent collection in C, specifically, an immutable hash trie. In order to increase acceptance and reusability, I have identified the following key areas that ...
1
vote
0
answers
112
views
Practice for modeling class - multiple container relationship
I have a class that could:
Have multiple types of containers
Have multiple types of implementations
and what I did to model so far is:
public interface ChildClass {
Container getContainer();
...
2
votes
3
answers
312
views
Single code fragment to perform two different operations
I want to manage music notes in a C# program, and I wrote a couple classes for that. However, I think I'm having trouble respecting the DRY principle. Either this or I'm overthinking things. Sorry if ...
4
votes
2
answers
1k
views
Differences between streams and iterators in C++?
I'm working on code which will provide a generic C++ interface to relational datasets. Some of the data will be in tables in memory (e.g. std::set or std::vector), but some of it will be computed - ...
0
votes
3
answers
1k
views
Definition of Generic function
1)
Below is a python function summation, that can perform sum of cubes/squares/.., similar operations.
def identity(k):
return k
def cube(k):
return pow(k, 3)
def square(k):
return ...
3
votes
3
answers
2k
views
Wrapping Controller / ApiController to remove boilerplates
We are aiming to reduce code noise that would be common for all Controllers such as basic CRUD.
public interface IGenericController<T, Y> where T : BaseMaster
{
IEnumerable<T> Get();
...
-1
votes
1
answer
115
views
What is the reason behing Tuples instead of HList in akka-http
As I can see in recent releases of akka-http, successor of spray, spray-routing's approach of using shapeless HList was replaced in favor of self-included Tuple
What is the motivation for this ...
1
vote
1
answer
161
views
Generic reactive collections of elements
In Visual Studio Color Theme Editor extension if you change some colors, some other related colors will change accordingly. They can become equal to the changed color or be more lighter/darker for ...
0
votes
2
answers
3k
views
Java - Does extending a class which itself extends a class which itself... and so on... is healthy..?
NOTE : Feel free to edit the title if it is somewhat different than my question.
In one of our application, we are maintaining a lot of properties inside Instance object. Obviously it's maintained as ...
1
vote
1
answer
428
views
Get or infer template type from inherited member
So I have an assignment from college where I have to apply multiple metaheuristics to different problems. I thought that I should make everything as modular and reusable as possible to reuse ...
5
votes
2
answers
4k
views
Generic Sorting of Lists<>
I have several Lists<> that holds objects of different classes.
List<classA> listA;
List<classB> listB;
List<classC> listC;
//...
List<classM> listM;
The classes do not ...
5
votes
1
answer
1k
views
Using macros to implement a generic vector (dynamic array) in C. Is this a good idea?
So far I have only done personal projects at home. I hope to get involved in some open source project some time next year. The languages I that have been using the most are C and C++. I have used both ...
0
votes
2
answers
539
views
Practical use of generic inheritance and interactions with non-generics?
I've been trying to learn more about generics, and I finally felt that I ran into a situation that it would be more useful to use it instead of only regular classes. Would the following be a practical ...
0
votes
1
answer
1k
views
Generic object construction - Inherited Classes
Basically I am writing a MSMQ based multi-threaded messaging pattern utility library. It's like a set of components all inherited (directly or indirectly) one class that's called my base component ...
1
vote
0
answers
147
views
Why isn't there parallel reduction in the Standard Template Library?
Alexander Stepanov stated in talks and interviews that his realization that eventually lead him to generic programming and the Standard Template Library, was from the case of the parallel reduction ...
3
votes
1
answer
751
views
Any programming languages that support Generics exclusively and have no OOP support? [closed]
I am writing a paper on the tension between OOP and Generic programming created by Stepanov. He widely criticizes OOP and says it is "technically flawed" when compared to Generic Programming.
Now I ...
7
votes
2
answers
4k
views
Writing generic code when your target is a C compiler
I need to write some algorithms for a PIC micro controller. AFAIK, the official tools support either assembler or a subset of C.
My goal is to write the algorithms in a generic and reusable way ...
1
vote
1
answer
297
views
Formal definition of "concepts / type system" for parametric types - Where to start?
I would be interested in formally defining (and consequently demonstrating) a "type system" for, well, a type system. More specifically, I would like to explore the idea of what C++ calls concepts for ...
3
votes
4
answers
5k
views
Are generic programming and OOP mutually exclusive?
I never did generic programming before, being more of a python guy, and generally using OOP. As I moved into generic programming, I faced some issues. I read the FAQ, but I am not satisfied. What I ...