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? Thanks, Jim
Avijeet Dash
Ranch Hand
Joined: Jan 21, 2001
Posts: 148
posted
0
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.
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
AFAIK: 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
Greenhorn
Joined: Jul 09, 2001
Posts: 12
posted
0
Thanks. So it looks like almost all Java objects are first-class objects. Do you have any example(s) showing non-first-class objects? Thanks.
Desai Sandeep
Ranch Hand
Joined: Apr 02, 2001
Posts: 1157
posted
0
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
posted
0
i guess, u r right.... immutable objects are not first-class objects.