Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC

 
Julio Cesar Marques
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody!

I like to get one or more opinion about my MVC [VC] to be exact! When i read and learn some thing about MVC i have a lot of theoretical examples, but no much practical examples... My doubt is simple: is this correct? (see pseudo-code)

MyController c = new MyController();

MyView v = new MyView(c);

//Inner MyView class exists a constructor:

MyView(MyController c){
c.setScreenToControl(this);
}

Is this Correct? Or there is a best way to associate controller/controlled classes?

Thanks!
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fala Julio!

Since we are talking about Swing, you can face ActionListeners as controllers, and JFrames as views. This is how I did the main window of my project:



So you can have an instance of the view in the controller.

Here is a very interesting article about GUI architectures, which also talks about the MVP pattern (a kind of MVC). I think it might be helpful!
 
Julio Cesar Marques
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again Bob!
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any difference between doing it like Roberto showed and using a seperate (anonymous) (inner-)class? And i mean difference in good or bad, from a design perspective ? I know there is a difference in code
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic