M
Marc Rochkind
To return an int (for example) through an argument, one can use a class
with an integer field. Three ways to do it come to mind:
1. Define a class named, say, IntHolder, with a public field:
public class IntHolder {
public int value;
}
2. Similar to #2, but make the field private and provide get and set
methods.
3. Instead of defining your own class, use the existing class
org.omg.CORBA.IntHolder.
Normally, one wouldn't code a class when a suitable one already exists, but
bringing in anything from org.omg.CORBA only for its holder classes seems
silly to me. It might confuse the reader more than including an extra class
would.
Similarly, normally one makes fields private and provides access functions,
but perhaps holder classes for primitive types is an exception. When the
only purpose of the class is to hold a primitive-type field, get and set
seem like overkill.
So, I am inclined to use #1 above.
Opinions?
--Marc
with an integer field. Three ways to do it come to mind:
1. Define a class named, say, IntHolder, with a public field:
public class IntHolder {
public int value;
}
2. Similar to #2, but make the field private and provide get and set
methods.
3. Instead of defining your own class, use the existing class
org.omg.CORBA.IntHolder.
Normally, one wouldn't code a class when a suitable one already exists, but
bringing in anything from org.omg.CORBA only for its holder classes seems
silly to me. It might confuse the reader more than including an extra class
would.
Similarly, normally one makes fields private and provides access functions,
but perhaps holder classes for primitive types is an exception. When the
only purpose of the class is to hold a primitive-type field, get and set
seem like overkill.
So, I am inclined to use #1 above.
Opinions?
--Marc