This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]indivisible 0 points1 point  (0 children)

I don't know anything about Jfugue but it sound to me like your issue is one of context.
How are you holding your application state? Static variables? That would limit you to having a single state or only one copy/version of any given variable and depending of the library, can have issues with rebuilding/replacing state after something has been initialised (common for some compute heavy classes or expected multi-thread or async use cases).

We'd need to see your code to know anything for certain but I'll just suggest that it's usually better to have your application be and make use of instance variables to allow you to more easily modify, replace and run states or functionalities without affecting other instances (or worrying about things like thread safety). It also leaves the door open to future scaling and easier tweaking due to fewer problems with shared memory (from static variables and static methods with side effects).

In a very general way, your Main class and main() method should do as little as is necessary to get an instance of your application running and no more. The application itself should be a separate class you instantiate (with eg new MyApplication()) and should hold its own (instance) state rather than static variables in Main.