Does Android's class BaseAdapter have "Adapter" in its name because it follows the Adapter pattern or is it just a coincidence?
In software engineering, the adapter pattern is a software design pattern (also known as wrapper, an alternative naming shared with the decorator pattern) that allows the interface of an existing class to be used as another interface.
Android provides several subclasses of Adapter that are useful for retrieving different kinds of data and building views for an AdapterView ( i.e. ListView or GridView). The common adapters are ArrayAdapter,Base Adapter, CursorAdapter, SimpleCursorAdapter,SpinnerAdapter and WrapperListAdapter.
If you do some research on the adapter pattern, you will find two different versions of it: The class adapter pattern that implements the adapter using inheritance. The object adapter pattern that uses composition to reference an instance of the wrapped class within the adapter.
From Wikipedia
In computer programming, the adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface.1 An adapter allows classes to work together that normally could not because of incompatible interfaces, by providing its interface to clients while using the original interface.
So, let's discect that. BaseAdapters specify an interface to use for programs that need adapters. In fact, this interface is called Adapter. This interface specifies the information needed to take an arbitrary list, and convert it to an arbitrarily long set of Views. BaseAdapter thus adapts your custom input format (In particularly, if you extend it), to the Adapter interface. Thus, it is an Adapter design pattern.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With