Skip to content

Clarify what is meant by "adapter pattern" in the Streams tutorial #821

Open
@nskins

Description

@nskins

In the Streams section of the tutorial, the following is written:

Functions that take a Stream and return another Stream are often called 'stream adapters', as they're a form of the 'adapter pattern'. Common stream adapters include map, take, and filter.

The Wikipedia article for Adapter pattern reads:

An adapter allows two incompatible interfaces to work together. This is the real-world definition for an adapter. Interfaces may be incompatible, but the inner functionality should suit the need. The adapter design pattern allows otherwise incompatible classes to work together by converting the interface of one class into an interface expected by the clients.

My understanding, therefore, is that functions like map, take, and filter (which are largely rooted in functional programming) wouldn't be forms of the adapter pattern (at most, map might be since it can convert from one type to another). My understanding could be flawed, and that's fine. If that's the case, we should link to the Wikipedia article (or preferably a better resource) that explains what is meant by the "adapter pattern" in this tutorial. If these functions are actually not following the adapter pattern, my recommendation would just be to remove the part that says "as they're a form of the 'adapter pattern'" to prevent confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions