Programming patterns - example study

design-patterns, java

Solution

That's an example of the Decorator Pattern.

As the linked Wikipedia article states:

Decorator pattern is a design pattern that allows behaviour to be added to an existing object dynamically.

In your example, you're adding buffering to a `FileReader`, which provides more efficient reading than a regular, un-buffered `FileReader`.

Problem

I had this question on my test: What kind of programming / design pattern is this: ``` FileReader fr = new FileReader("file.txt"); BufferedReader bf = new BufferedReader(fr); ``` I'm sorry for the trouble, but definitions of programming patterns are unclear for me and I don't know how to answer this question correctly.

Original source

Related problems