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.
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
.
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