#Should I keep code to one script or use multiple interfaces to keep organized?

1 messages · Page 1 of 1 (latest)

maiden terraceBOT
#

<@&987246399047479336> please have a look, thanks.

maiden terraceBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

quartz ocean
#

Let me explain specifically

#

I have a class and an interface

#

The class extends the interface

#

I have defined a method in the interface with a return put into it so as I call the specific method it should come out with a certain variable

#

Problem is, I have ran into the problem of eventhandling, to which I may be going off of the right track

#
// This is simplified
interface thisinterface {
    default Pane thispane() {
        Pane apane = new Pane(); // A Pane
        Button foo = new Button();

        // Variables defined for both of these to then come to the return statement

        return apane;
    }
}
maiden terraceBOT
quartz ocean
#

class thisclass implements thisinterface {
    Parent thisparent {
        // All that  stuff...
    }
    @Override

    public void start(Stage stage) throws Exception {
        stage.setScene(new Scene(apane(), 300, 300));
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
} ```
maiden terraceBOT
quartz ocean
#

Now I come into the problem

#

I need to use apane which is fine

#

But I also have the button

#

I need to use an eventhandler

grizzled trout
#

why not use an abstract class instead?

quartz ocean
#

can you extend multiple of those?

grizzled trout
#

no

quartz ocean
#

Well, the structure of my program uses multiple of these panes

#

I wanted to organize them into the interfaces

grizzled trout
#

Fine, a simple solution would be to instead of returning Pane return a container class that has a reference to Pane Button etc.

#

You shouldn't really be using default methods

quartz ocean
#

I should've looked it up

quartz ocean
#

Does it being a simple solution affect anything?