在哪里,这个词是如何使用的编程包装器,这是什么帮助呢? [英] Where and how is the term used WRAPPER in programming, what does it help to do?

查看:181
本文介绍了在哪里,这个词是如何使用的编程包装器,这是什么帮助呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到使用创建其他类或API,甚至有些代码封装器的长期的软件开发者,这是由经验丰富的软件编程使用的一个术语

I come across software developers using the term of creating Wrappers of other classes or APIs or even some codes, this is a term used by experienced Software Programmers

因此​​,任何想法是什么?他们通过意思;

So any idea what do they mean by it;

如一个简单的问题;我们有两种类型的数组排序技术,让我们创建一个包装它。

e.g. a simple question; we got two types of array sorting techniques, lets create a wrapper for it

上面的是一个很简单的例子

The above one is a very simple example

推荐答案

术语包装,被周围很多抛出。它一般用来描述包含另一个类的一个实例类,但不直接公开该实例。包装的主要目的是提供一种不同的方式来使用包装对象(或许包装提供了一个简单的接口,或增加了一些功能性)。

The term 'wrapper' gets thrown around a lot. Generally its used to describe a class which contains an instance of another class, but which does not directly expose that instance. The wrapper's main purpose is to provide a 'different' way to use wrapped object (perhaps the wrapper provides a simpler interface, or adds some functionality).

的单词包装'也可以被描述经典的设计模式时使用。

The word 'wrapper' can also be used when describing classic design patterns.

包装纸一个目的是提供一种简化的界面,它经常被描述为正面的图案。该包装是门面。

Wrapping an object to provide a simplified interface to it is often described as the 'Facade' pattern. The wrapper is the facade.

有时,你可能有这将符合特定接口的类,但你不能改变它的代码,使之符合该接口。您可以创建该类它实现了接口的包装,但它指导大多数调用被包装的对象。这就是适配器格局。该包装是适配器。

Sometimes you may have a class which would suit a specific interface, but you can't change the code for it to make it conform to that interface. You can create a wrapper for that class which implements the interface, but which directs most of the calls to the wrapped object. This is the 'Adapter' pattern. The wrapper is the adapter.

您所描述的情况,你有两个类,可以做阵列使用不同的算法排序听起来像'战略'的模式,在那里你提供一种方法,一些物体上执行的操作,但用于该操作的算法可以根据该对象的结构是不同的。

The instance you describe, where you have two classes which can do array sorting using different algorithms sounds like the 'Strategy' pattern, where you provide a way to perform an operation on some object, but the algorithm used for that operation may be different depending upon the structure of that object.

例如,你的排序中的一个算法可用于长度小于100的阵列是巨大的,但随后的表现可能是一个问题吧。其他算法可能有利于更大的阵列。您可以为这两种算法一个包装,支持排序操作,但决定使用基于阵列的长度,它的算法。

For example, one of your sort algorithms may be great for arrays of length less than 100, but then performance might be an issue for it. The other algorithm might be good for bigger arrays. You can create a 'wrapper' for the two algorithms which supports the sort operation but decides which algorithm to use based on the array length.

绝大多数包装的存在隐藏某种复杂性。

The vast majority of wrappers exist to hide some sort of complexity.

这篇关于在哪里,这个词是如何使用的编程包装器,这是什么帮助呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆