Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: generic programming  (Read 3305 times)

0 Members and 1 Guest are viewing this topic.

EEVIAC

  • Guest
generic programming
« on: April 20, 2010, 08:52:06 AM »
What is it ?

Salmon Trout

  • Guest
Re: generic programming
« Reply #1 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.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: generic programming
« Reply #2 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.
I was trying to dereference Null Pointers before it was cool.

EEVIAC

  • Guest
Re: generic programming
« Reply #3 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..



Big



    Beginner

    Thanked: 4
    • Experience: Experienced
    • OS: Windows XP
    Re: generic programming
    « Reply #4 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
    « Last Edit: April 21, 2010, 10:04:43 AM by Big »
    Computerhope is corrupt.