![]() What does the ipad do that the iphone doesn't do?Īren't they basically the same thing, except one has a bigger screen? Simple Explanation by Analogy: What is wrapping?Ĭode not used to explain. The vast majority of wrappers exist to hide some sort of complexity. 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 other algorithm might be good for bigger arrays. ![]() 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.įor 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. You can create a wrapper for that class which implements the interface, but which directs most of the calls to the wrapped object. 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. Wrapping an object to provide a simplified interface to it is often described as the 'Facade' pattern. ![]() The word 'wrapper' can also be used when describing classic design patterns. 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). Generally its used to describe a class which contains an instance of another class, but which does not directly expose that instance. The term 'wrapper' gets thrown around a lot.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |