Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is meant by "implement a wrapper method"?

I have been given a programming assignment and one of the things I have to do is implement method which a wrapper method which relies on another method to sort the coordinates from lowest to highest. I am unsure on what exactly is meant by implementing a wrapper method.

static void sortCoordsByZ(double[][] coords) {
    //implement the wrapper method for the recursive sort method. all work is done the recursive sort method
}

static void recursiveSort(double[][] coords, int lo, int hi) {
    //recursive sort method
}
like image 675
Shawn Avatar asked Nov 15 '09 01:11

Shawn


2 Answers

A wrapper method is an adapter or a façade; it provides an alternative interface for an existing method.

You've been asked to write a façade (facade) - to provide a simpler interface for clients that don't need to specify high and low values.

like image 114
Jeff Sternal Avatar answered Sep 20 '22 02:09

Jeff Sternal


You're acting as a wrapper method right now by asking your assignment question on Stack Overflow!

A wrapper method answers a question by asking an "expert" method for the answer. Generally, it does three things:

  1. It frames the question in such a way that the "expert" method can understand it.
  2. It asks the "expert" method the question
  3. It does something easy to the answer to put it in the right format for the caller.

In your case, the "expert" method is recursiveSort(), and your sortCoordsByZ() method will have to call recursiveSort() with the right parameters, and then maybe do something with the answer before returning it.

like image 40
Grandpa Avatar answered Sep 21 '22 02:09

Grandpa