In the process of talking about builders, the author talks about the JavaBeans. * The Author class model a book's author. Java 7 introduces the diamond operator, so this can become: Mapprivate member variables: name ( String), email ( String), and gender ( char of either 'm' or 'f' - you might also use a boolean variable called isMale having value of true or false).1: The Author and Book Classes Let's start with the Author classĪ class called Author is designed as shown in the class diagram. We shall begin with reusing classes via composition - through examples.
With inheritance, you derive a new class based on an existing class, with modifications or extensions. With composition (aka aggregation), you define a new class, which is composed of existing classes. There are two ways to reuse existing classes, namely, composition and inheritance.