Sunday, July 22, 2007

Data Objects

Is a data object the same thing as an object-oriented class? No.

Example
(1) Data Object implemented as a class
public class Car {
private Engine engine;
private boolean can_load=false;
}

(2) There can be reference within a class object to operations that act on the data.
public class Car {
private Engine engine;
private boolean can_load=false;
public Car()
{
engine= get_engine();
}
final public boolean can_load()
{
return can_load;
}
private Engine get_engine()
{
Engine my_engine;
can_load=true;
my_engine=Engine.getobject(this) ;
can_load=false;
return my_engine;
}
}

Note: the source code is from http://www.ibm.com/developerworks/cn/java/l-single-call/index.html

No comments: