Computer Hope

Software => Computer programming => Topic started by: EEVIAC on April 20, 2010, 08:52:06 AM

Title: generic programming
Post by: EEVIAC on April 20, 2010, 08:52:06 AM
What is it ?
Title: Re: generic programming
Post by: Salmon Trout on April 20, 2010, 11:06:41 AM
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.
Title: Re: generic programming
Post by: BC_Programmer on April 20, 2010, 02:06:13 PM
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.
Title: Re: generic programming
Post by: EEVIAC on April 21, 2010, 08:43:40 AM
I still don't get it     ;D



It's ok.  I'm confident that I'll know what it is, in time..


Title: Re: generic programming
Post by: Big on April 21, 2010, 09:54:38 AM
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<Human> humans = new List<Human>();
List<Cheese> cheeses = new List<Cheese>();

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. :P