File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Separating the business logic from the gui components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Separating the business logic from the gui components" Watch "Separating the business logic from the gui components" New topic
Author

Separating the business logic from the gui components

Mansi Dave
Ranch Hand

Joined: Aug 06, 2002
Posts: 49
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

Joined: Oct 08, 2001
Posts: 2937

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

Joined: Aug 06, 2002
Posts: 49
Thanks for the information. Is there any reading material available for this where I can get examples?
Mansi
 
 
subject: Separating the business logic from the gui components