M
m97rek
I have a question with regards to program design.
If I have a class that looks something like:
public class SampleApp extends Engine implements Listener_OnMyEvent
{
public static void main(String argv[])
{
int x=10;
//Call metod1
Method1(x);
}
public method1(int i)
{
//Call a method from the Engine Class
//I know I don't have to have "Engine." here but it's just to
clearify
Engine.method2();
}
public void OnMyEvent()
{
Log("Event Hapended");
}
}
Let's say now that I want to move method1 to another class/file in
order to keep the code as neat and tidy as possible.
How should I do that? What is best practice according to you? Should
the methods there be static?
I tried to create:
public class MyMethods
{
public static method1(int i)
{
Engine.method2();
}
}
....but then method2 isn't available since Engine isn't implemented
unless I pass the whole class along:
MyMethods(x, this)
Is this correct?
I hope you see what I'm getting at here.
Any suggestions is appreciated.
Thanks
If I have a class that looks something like:
public class SampleApp extends Engine implements Listener_OnMyEvent
{
public static void main(String argv[])
{
int x=10;
//Call metod1
Method1(x);
}
public method1(int i)
{
//Call a method from the Engine Class
//I know I don't have to have "Engine." here but it's just to
clearify
Engine.method2();
}
public void OnMyEvent()
{
Log("Event Hapended");
}
}
Let's say now that I want to move method1 to another class/file in
order to keep the code as neat and tidy as possible.
How should I do that? What is best practice according to you? Should
the methods there be static?
I tried to create:
public class MyMethods
{
public static method1(int i)
{
Engine.method2();
}
}
....but then method2 isn't available since Engine isn't implemented
unless I pass the whole class along:
MyMethods(x, this)
Is this correct?
I hope you see what I'm getting at here.
Any suggestions is appreciated.
Thanks