使用 MVC 开发桌面应用程序的推荐书籍 [英] Recommended books on Desktop Application development using MVC

查看:26
本文介绍了使用 MVC 开发桌面应用程序的推荐书籍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关桌面 MVC 书籍的推荐.如果他们使用 Java,那就太好了.

I'm looking for recommendations on books about MVC on the desktop. If they use Java, that is a bonus.

一些背景:我正在用 Java 编写桌面应用程序.它是一个音频应用程序,具有多个视图和一个称为库的中央模型,其中包含播放列表、效果列表和用于组织它们的文件夹结构.在这个应用程序中,我希望为各种用户操作提供菜单、上下文菜单和拖放支持.我一直在为如何使用 MVC 实现这一目标而苦苦挣扎.

Some background: I'm writing a desktop application in Java. It's an audio application that has a number of views and a central model called a Library with playlists, effects lists and a folder structure to organize them. In this application I'd like to have menus, context-menus and drag and drop support for various user actions. I've been struggling with how to achieve this using MVC.

我从主类中的所有逻辑/控制器开始,但已开始将它们分成自己的类.现在我需要开始使用监听器和观察器来处理视图和控制器之间的消息.这导致我创建了许多接口并在几个地方循环我的听众以触发各种消息.但是该循环代码不断重复(不是 DRY),所以我假设现在我应该创建不同类型的 Event 类,在我的视图中创建这些事件并在视图中使用一个方法将其发送给各种侦听器.

I started with all the logic/controllers in the main class but have started to separate them out into their own classes. Now I need to start using listeners and observers to handle messages between the views and the controller. This led to me creating a number of interfaces and looping through my listeners in several places to fire off various messages. But that loop code keeps getting repeated (not DRY), so I'm assuming that now I should create different types of Event classes, create those events in my views and use a single method within the view to fire it off to the various listeners.

更新:可以说这应该没什么关系,但我使用的是 SWT,而不是 Swing.

Update: Arguabley it shouldn't matter much but I'm using SWT, not Swing.

推荐答案

我遇到了同样的问题:编写一个(非平凡的)swing 应用程序确实需要很多纪律,因为所有的侦听器和事件都是异步的对于一大堆不可维护的代码,处理速度非常快.

I've had the same problem: it really takes a lot of discipline to write a (non trivial) swing app, because all the listeners and events and asynchronous processing make up really fast for a big pile of unmaintainable code.

我发现经典的 MVC 是不够的,你必须研究更具体的模式,比如 Presentation Model 之类的.我发现在应用于桌面应用程序时涵盖这种模式的唯一一本书是 Desktop Java Live,作者:斯科特·德拉普.虽然大多数 Swing 书籍都涉及解决特定问题的技术(如何制作无网格 jtable、如何实现圆形按钮等),但 Delap 的书将帮助您构建中型 Swing 应用程序、最佳实践等.

I found that classic MVC isn't enough, you have to look into more specific patterns like Presentation Model and such. The only book I found covering this patterns when applied to desktop applications is Desktop Java Live, by Scott Delap. While the majority of swing books deal with techniques to solve specific problems (how to make a gridless jtable, how to implement a round button, ...), Delap's book will help you architect a medium-sized swing application, best practices, etc.

这篇关于使用 MVC 开发桌面应用程序的推荐书籍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆