Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

First class object -- what is it?

 
Jim Dong
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Avijeet Dash
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess, u r right....
immutable objects are not first-class objects.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic