jQuery in Action, 2nd edition*
The moose likes OO, Patterns, UML and Refactoring and the fly likes First class object -- what is it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "First class object -- what is it?" Watch "First class object -- what is it?" New topic

First class object -- what is it?

Jim Dong

Joined: Jul 09, 2001
Posts: 12
Hi there,
I have encountered the term "First class object" in the GoF book "Design Pattern", when it comes to Command pattern. Since I have not seen this term before, I searched around and did not find anything satisfying. So I would like to ask for some help here. Does anybody know what "First class object" mean?
Avijeet Dash
Ranch Hand

Joined: Jan 21, 2001
Posts: 148
just to put the question other way..
command objects are first-class objects, that is they can be manipulated and extended like other objects.
so does it mean objects which can't be extended (final) and can not be manipulated (when???) are not first class objects.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
A language supports some data type as first-class when the objects of the type can be created and used as data at run time. First-class data can be kept in variables, and passed to and returned from functions. In dynamically typed languages, first-class data can also have its type examined at run-time.
Jim Dong

Joined: Jul 09, 2001
Posts: 12
Thanks. So it looks like almost all Java objects are first-class objects. Do you have any example(s) showing non-first-class objects?
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Is an immutable object a first class object?
For example, if I have an object only with getter methods and no setter methods, will it mean that the object is non-first class object.I have taken care of one consideration of non-first class object; i.e. avoiding its manipulations.
Comments please!
-- Sandeep
SCJP2, OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)
[This message has been edited by Desai Sandeep (edited July 25, 2001).]

<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Avijeet Dash
Ranch Hand

Joined: Jan 21, 2001
Posts: 148
i guess, u r right....
immutable objects are not first-class objects.
wood burning stoves
subject: First class object -- what is it?
Similar Threads
Adapter or Mediator?
Repairing Objects
User defined First class objects
What does "POJO" mean?
Decorator pattern