8 IMMUTABLE OBJECT

This pattern was previously described in Grand98.

DESCRIPTION

In general, classes in an application are designed to carry data and have behavior. Sometimes a class may be designed in such a way that its instances can be used just as carriers of related data without any specific behavior. Such classes can be called data model classes and instances of such classes ar e referred to as data objects. For example, consider the Employee class in Figure 8.1 and Listing 8.1.

Employee
firstName:String
lastName:String
SSN:String
address:String
car:Car
________________________________
getFirstName():String
getLastName():String
getSSN():String
getAddress():String
getCar():Car
setFirstName(fname:String)

Get Software Architecture Design Patterns in Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.