Skip to Content
Java Program Design: Principles, Polymorphism, and Patterns
book

Java Program Design: Principles, Polymorphism, and Patterns

by Edward Sciore
December 2018
Intermediate to advanced
465 pages
8h 5m
English
Apress
Content preview from Java Program Design: Principles, Polymorphism, and Patterns
© Edward Sciore 2019
Edward ScioreJava Program Designhttps://doi.org/10.1007/978-1-4842-4143-1_8

8. Decorators

Edward Sciore1 
(1)
Newton, MA, USA
 

A decorator is a wrapper that implements the same interface as the object it wraps. Decorator methods enhance the methods of the wrapped object, in contrast to adapter methods, which replace the methods of the wrapped object.

This chapter examines several useful applications of decorators. They can be used to create immutable versions of objects, coordinate the execution of complex tasks, and implement collection streams. The Java library class InputStream uses decorators prominently. The chapter also examines the design issues that the writers of decorator classes must confront.

Decorator Classes

Let’s begin ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Design Patterns and SOLID Principles with Java

Design Patterns and SOLID Principles with Java

Róbert Kohányi
Design Patterns and Best Practices in Java

Design Patterns and Best Practices in Java

Kamalmeet Singh, Ianculescu, Lucian-Paul Torje

Publisher Resources

ISBN: 9781484241431Purchase LinkPublisher Website