Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC and Client GUI (B&S)

 
Alexander Fritz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I would like to know your opinions about my approach for the client GUI design. I have two main classes, one which handles with the GUI (buttons, combo boxes and a JTable) and other implementing the data model. The data model extends an AbstractTableModel and is used by the JTable component in the GUI.

To connect both classes I have used adapter classes. Moreover, I delegate all the logic regarding the data to the data model class. That means for instance, that when a user presses the book button, an adapter class signals the data model to connect to the database and update its data accordingly.

However, a colleague from me says that it is better to move the logic connecting the database to the adapter class (opposite to my approach) and then, once the adapter class retrieves the new data, it is passed to the data model to also update the data displayed in the GUI.

My decission is based on the opinion that when future enhanecements are needed, such as move to another database system, it will be only necessary to rewrite the model thus, reusing the GUI and the adapter classes.

But as I'm not an expert in design patterns, I'll be very glad to hear about your approaches to this problem.
 
Anthony Bull
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I went with the same approach as you. An adapter should NOT be implementing business rules, as it is simply adapting your service/business model to be accessible over a network. Don't listen to your colleague, you are on the right track! Sounds like your colleague hasn't done the certification yet.
 
Alexander Fritz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your comment. I am ready to submit (in fact I was thinking to do it within this week) and wanted to know some oppinions.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic