Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Separating the business logic from the gui components

 
Mansi Dave
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,
I'm in the process of designing a GUI application using Swing. Is there any information available on the correct way to separate the business logic from the GUI piece? For example, if I want to create a GUI screen which accepts user information(i.e. name, ss#, phone #, etc), where is the right place to put the validation code? I plan on creating a User class to store this information. But should the validation code go in this class as well?
Hope this makes sense.
Mansi
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm in the process of designing a GUI application using Swing. Is there any information available on the correct way to separate the business logic from the GUI piece?

Well, there are many "correct" ways to do it, but more or less universal one is Model-View-Controller (MVC) pattern (or a bit more simplified Model-View pattern). The model is the class that contains business logic, the view(s) are your GUI frames, and the controller is the class that acts as a listener to user events, calls the methods of model, and selects the views. The model can also update the view(s) using some weakly-typed notification.
Eugene.
 
Mansi Dave
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the information. Is there any reading material available for this where I can get examples?
Mansi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic