jeudi 16 mai 2019

Does `BufferedReader` follow the decorator pattern? [duplicate]

This question is an exact duplicate of:

Does BufferedReader use the decorator pattern?

BufferedReader is a subclass of Reader.

  1. But BufferedReader has only one field lock with type Object, instead of a field of type Reader. So it doesn't seem to use the decorator pattern.
  2. But BufferedReader has constructors BufferedReader​(Reader in) and BufferedReader​(Reader in, int sz), both having an argument of type Reader, which seems to me that BufferedReader should have a field with type Reader and therefore BufferedReader should follow the decorator pattern. Why do the constructors have an argument of type Reader, if it doesn't have a field of type Reader?

    Thanks.

Aucun commentaire:

Enregistrer un commentaire