How to structure a program
in
Programming Questions
•
1 years ago
Hello everyone,
I've been working on a sketch for some time now. It's a program that converts JPGs into animated GIFs.
And one of my biggest issues was "how to structure the program"?
The user has to go through different states/pages of the program. And I wanted to structure the classes in a way they would communicate with each other in harmony.
By researching, I came across two solutions:
// Listeners //
I asked a couple of friends who do some other programming languages and they told me to use "listeners".
Researching listeners on the forum, I've come to find this:
https://forum.processing.org/topic/custom-events-event-listener
From that, I understood that either I would learn
"Observer and Observable java" or I would use a library named "toxiclibs".
// Draw loop //
I also had a look at the forum and found that games could have a similar structure. And some people suggested to use a switch (condition) on the draw loop, using a variable to keep track of it.
Please, don't take me wrong, but the latter solution using the draw loop doesn't seem to be very object oriented.
I could be totally wrong, but it just don't look right.
But maybe it's the way Processing works, and I'm fine accepting it.
I also thought "maybe processing is not meant to do this". But I wanted to have an opinion from the community if possible. These are my first bigger steps into processing.
So, the question is: which way should I take?
I hope that it's a clear question.
Should I post the code? It's a bit long.
It just looks awful now, but it works. My next step is to polish it.
1