Click to See Complete Forum and Search --> : Wrapper


NC
04-15-2007, 01:42 AM
What is a wrapper in computer programming?

eshbach
04-15-2007, 02:02 AM
What is a wrapper in computer programming?

There are probably a couple valid definitions, but the first one that comes to mind is the concept of an object that contains functions for a specific primitive type.

In java, for instance, there is a class called Integer which is a "wrapper" for the primitive type int. Since java primitives aren't objects, they can't contain other primitives, objects, or methods. Some functions, such as parsing and conversion, are essential to effective object-oriented programming, and so the wrapper class provides that functionality for the primitive.

NC
04-15-2007, 03:19 AM
Can a a primitive be a basic function like a goto or an if /then statement?

eon
04-15-2007, 12:04 PM
i think primitives are basic data types so i dont think it can be a function
but a wrapper can be used on functions and classes, from my classes it was defined as a class that encapsulates another class to give it a new interface

skoechle
04-15-2007, 07:13 PM
i think primitives are basic data types so i dont think it can be a function
Exactly a primitive is a data type like int, char, double, boolean, float...

Strogian
04-15-2007, 10:15 PM
A wrapper is anything that wraps around something else. If you want to define wrapper as something that defines a new interface for a primitive, then 'goto' or 'if/then' would count as a primitive. If you write a function to do an if/then statement, then you've written a wrapper:


Function IfThen (Function if_code, Function then_code)
If if_code() Then
then_code()
End If


Maybe wrapper is most often associated with object oriented programming, and then yeah it would be an object that wraps another object. Otherwise, the key point is just that it defines a new interface for something.