|
Answer» What is it ?Generic programming is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types provided as parameters. In VB.NET, C#, and most other .NET languages, this functionality is provided by native CLR SUPPORT for generic type CLASSES. In fact, a good number of classes in the framework are generic classes- ArrayList, List, etc.
C++ doesn't support a functionality CALLED "generics" but it's template classes are nearly the same. The difference is that, strictly speaking, (and, if I underastand it correctly) template classes are really just sets of macros that expand to create an entirely new class definition for each type that you specify.
At first I MISINTERPRETED the question as "genetic programming" which is a fair bit different, and a lot harder to answer.I still don't get it
It's ok. I'm confident that I'll know what it is, in time..
Translate to nooblang. :O 'Neurolinguistic Programming' is even harder to answer.
I'll TRY to explain (from what I understand here):
You have a list of 'templates'. These are the 'generic' classes. By generic, one simply means 'all-round', 'not specific'. Let's try to do an analogy:
I have defined the generic type 'list'. We all know what a list is, but the computer will never know what on earth you want to make it a list of, or what you want to put in that list.
Therefor, later, you put a bunch of humans in that list, for example (lol). Now, it is a list of humans.
Code example:
List humans = new List(); List cheeses = new List();
In these examples, the generic types are Human and Cheese. One list contains humans, the other contains cheeses.
I hope that helps to explain it because I don't know much of generic types myself.
|