jeudi 16 novembre 2017

Dealing with Dependencies when instantiating MVC objects in Java

I know that's not the most amazing title in the world, but bear with me. I'm developing an application in Java, for part of which I'm using the MVC design pattern.

UML

Above is my understanding of the MVC structure, or at least how I'm choosing to implement it. However I've run into a problem instantiating the objects. Since any given controller requires a reference to it's view pair, and any given view requires a reference to it's controller pair, I'm not sure how to actually create the objects.

I could pass the view into the controller as null and then immediately set it, but not only does this feel like bad coding practice it raised questions about where I actually should be creating the view. Is it something normally delegated to the controller? Any guidance would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire