Search code examples
javadesign-patternsn-tier-architecture

Pass variables from Presentation Layer to Logic Layer


I am stuck when I try to make the Logic Layer update the Presentation Layer since I have initialized GUI variables in the Presentation Layer. Still, after that, I couldn't find a way to reach those variables from the Logic Layer. I don't believe that I should make all variables public to reach them.

I have an example here:

  • Logic Layer method that updates multiChoicePanel

    public void clearDisplay() {
              if (currentlyDisplayedQuestion.getQuestionType() == QuestionType.MULTI_CHOICE) {
                  multiChoicePanel.clearDisplay();
              } 
             else
              ...
          };
    
  • Presentation Layer where i have declared multiChoicePanel

      private JQEMultiChoiceQuestionScreen multiChoicePanel;
    

So the question here is how to pass multiChoicePanel to Logic Layer?


Solution

  • I solved this question by moveing clearDisplay() in the Presentation Layer and make the Logic Layer expose its functionality through methods.