1

I'm wondering how I would use a Facade Design pattering in tandem with an MVC pattern in order to change a view when a button is pressed...

I don't have much experience with the Facade pattern (all I've done is simple printouts) so I'm kinda stuck in the water with this one.

UML Showing Class Structure uml

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • You should add (a lot) more details to make the question more specific and perhaps include an [mcve](http://stackoverflow.com/help/mcve) or uml diagram that demonstrates what you are have so far (for instance your implementation of the MVC pattern that you mention in your question). Otherwise, the question is too vague to be well answered here IMO. – jewelsea Apr 27 '16 at 23:39
  • Only problem with that is that the whole thing spreads about 15 classes because of the nature of MVC. – Shawn Williams Apr 27 '16 at 23:41
  • 1
    The idea of a minimal mcve or uml diagram would be that you remove all the classes and implementation that is not required to immediately demonstrate the issue at hand, but still provide an executable sample somebody could copy and paste to run and replicate your issue. That really shouldn't require 15 classes unless you had an extremely involved MVC architecture, in which case the question probably wouldn't be answerable on StackOverflow anyway. For example, these [facade samples](https://en.wikipedia.org/wiki/Facade_pattern) are only 3-4 classes. – jewelsea Apr 27 '16 at 23:44
  • updated with a basic uml diagram showing the basics of what im doing. I didnt want to include any code someone could just C&P. – Shawn Williams Apr 27 '16 at 23:52
  • That's fine, for a design question, executable code is optional, but the UML is likely quite helpful to a potential answerer. – jewelsea Apr 27 '16 at 23:56
  • If the controller needs to care about the structure of the model beyond the top level class it deals with, something is wrong. Not clear why the model matters here and that's 80% of the picture. Also not sure a facade is needed to have a controller change a view. Facades are traditionally used to hide a complex interface. Don't think a button click rises to that level of complication. – dbugger Apr 28 '16 at 02:25
  • Have a look at [this article](https://dzone.com/articles/design-patterns-uncovered-1) and tell us what the fa4ade should do. – hotzst Apr 28 '16 at 05:46

1 Answers1

0

Some libraries already exist implementing different pattern, from simple MVC with FXML, FXMLController and Object) to more sophisticated one like MVVMFX or others.

For instance JRebirth Application Framework uses the Facade pattern with a 2-level MVC pattern. An MVC for whole application and another MVC for UI with optional parts. The facade pattern is used to manage reusable components in a loosely coupled way. It also provides an Event Bus to let components communicate with each other.

So instead of reinventing the wheel read the code of existing libraries to known if it can suit your needs and then choose to contribute or to start a more innovative framework.

The full pattern is described in this topic MVC with javaFX

Sébastien B.
  • 545
  • 4
  • 9