R
RFleming
Hello,
I have recently learned Java (under pressure) not in a bad way.. We
had a person leave the company and I was next best suited to take over
where he left off.....
Anyway, I have gotten pretty comfortable, but still have a long way to
go..
My question is one on passing objects from class to class.....
Say I have a Screen superclass (I believe that is the right term)
The screen creates one object from the class Model.
The class called Model with an array of 100 widgets objects from the
widgets class... Model.Widget(intIndex).blahblah
I have several screens, subclasses of the Screen class.
Each subclass gets Model passed into it when it is created
Example below
public class ScreenCircuitControl implements Screen {
public ScreenCircuitControl(Model model){
this.model = model;
}
private String getWidgetInfo(int intIndex){
return model.widget(intIndex).getinfo();
}
private Model model;
}
Example ends
Each other screen is set up similarly. I access the Widget class by
typing Model.Widget.......
Is this the most memory efficient/best way, or at least a decent way,
or is this bad?
It is my understanding that I am passing model by reference thus not
creating duplicate memory locations with memory allocated for 100
widgets in each screen....
Any comments would be greatly appreciated
Thanks
Ryan
I have recently learned Java (under pressure) not in a bad way.. We
had a person leave the company and I was next best suited to take over
where he left off.....
Anyway, I have gotten pretty comfortable, but still have a long way to
go..
My question is one on passing objects from class to class.....
Say I have a Screen superclass (I believe that is the right term)
The screen creates one object from the class Model.
The class called Model with an array of 100 widgets objects from the
widgets class... Model.Widget(intIndex).blahblah
I have several screens, subclasses of the Screen class.
Each subclass gets Model passed into it when it is created
Example below
public class ScreenCircuitControl implements Screen {
public ScreenCircuitControl(Model model){
this.model = model;
}
private String getWidgetInfo(int intIndex){
return model.widget(intIndex).getinfo();
}
private Model model;
}
Example ends
Each other screen is set up similarly. I access the Widget class by
typing Model.Widget.......
Is this the most memory efficient/best way, or at least a decent way,
or is this bad?
It is my understanding that I am passing model by reference thus not
creating duplicate memory locations with memory allocated for 100
widgets in each screen....
Any comments would be greatly appreciated
Thanks
Ryan