Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
3answers
272 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
2answers
579 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
3answers
879 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
3answers
1k 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
1answer
100 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
1answer
119 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
2answers
1k 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
1answer
270 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
2answers
2k 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
1answer
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 ...
1
vote
2answers
450 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
1answer
858 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
0answers
142 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
1answer
561 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 ...
6
votes
2answers
3k 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
1answer
266 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 ...
2
votes
4answers
3k 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 ...