What does "wrapping" mean in programming?
Asked Answered
P

2

10

In programming literature and on internet in general I noticed frequent use of term "wrapping".

For example "to wrap library in classes" or to "wrap database". Is that official in programming or just a slang? And what is the best way to describe it?

Pulsimeter answered 16/3, 2012 at 21:9 Comment(0)
H
15

"Wrap" is a standard English word meaning "Cover or enclose". Typically programmers use it to mean enclosing the functionality of something with something else. It's a fairly widely accepted term. There is no "official programming terms" guideline, so that's about as close as it gets.

Example:

  • a wrapper function is a function that calls another function;
  • a wrapping class is a class that holds inside itself a reference to another object;
  • the Facade design-pattern is a class/object that wraps around another object, for the purpose of simplifying the interface to access/use such object;
  • a Decorator design-pattern is a class/object that wraps around another object at run-time, for the purpose of enhancing the object's interface with new functionality (without having to modify the object itself).
Heaps answered 16/3, 2012 at 21:14 Comment(3)
Hi Amber - would you be able to elaborate on the following re: wrappers - that they: "enclose the functionality of something with something else."?Gink
Quite late to the party but I added some examples to the answer. I hope they make the "wrapper" concept more clear for other users.Cavein
I think the key word or idea to focus on is "interfaces". the wrapper presents a different interface to the user of whatever is being wrapped.Photofluorography
H
0

I found an awesome framework full of handy features but it was made with C++ but my project is written in C# .NET, and while I was basically re-writing the entire thing someone sent me a link to a wrapper for the whole C++ framework that allows me to use it with C# syntax.

So apparently wrapper just means you literally encase the content for use with different applications? Not really sure honestly, even though I'm using one.

Hypophosphate answered 5/4, 2024 at 2:53 Comment(1)
If you’re not really sure, why answer, and especially when there’s already an established answer that’s been validated by the community?Identical

© 2022 - 2025 — McMap. All rights reserved.