E
exquisitus
I'm porting code from C++ to Java. I have functions that have in/out
parameters - i.e. accept references (i.e. pointers and pointers to
pointers). In C++, this allowed me to return more than one variable.
In Java, I'm having to decompose such functions into several smaller
functions. To avoid code bloat (and also reduce typing errors/increase
maintainability of the handcrafted Java code - going forward). I want to
have each of these smaller functions to be merely a "wrapper" function
for a single block of code. Since I don't want this block of code to
show up in the (Java) API, I want to make it a private function (method).
My question then is that I can I then return the private object it
returns?. Here is some pseudocode to illustrate further:
class myClass {
....
public XObject foo_1(...)
{
XObject t = null ;
t = foo_hidden(...) ;
return t ; //Will this object be visible to callee ?
}
private XObject foo_hidden(...)
{
XObject x = null ;
//Some stuff here
return x ;
}
};
If this will not work, could someone please explain why it won't, and
equally importantly, how to "wrap" up a function as I explained - to
avoid having to repeat almost identical code several times in seperate
function calls.
Ta
parameters - i.e. accept references (i.e. pointers and pointers to
pointers). In C++, this allowed me to return more than one variable.
In Java, I'm having to decompose such functions into several smaller
functions. To avoid code bloat (and also reduce typing errors/increase
maintainability of the handcrafted Java code - going forward). I want to
have each of these smaller functions to be merely a "wrapper" function
for a single block of code. Since I don't want this block of code to
show up in the (Java) API, I want to make it a private function (method).
My question then is that I can I then return the private object it
returns?. Here is some pseudocode to illustrate further:
class myClass {
....
public XObject foo_1(...)
{
XObject t = null ;
t = foo_hidden(...) ;
return t ; //Will this object be visible to callee ?
}
private XObject foo_hidden(...)
{
XObject x = null ;
//Some stuff here
return x ;
}
};
If this will not work, could someone please explain why it won't, and
equally importantly, how to "wrap" up a function as I explained - to
avoid having to repeat almost identical code several times in seperate
function calls.
Ta