如何为Java应用程序的用户前端决定使用Swing GUI还是轻量级web客户机?

时间:2021-04-29 12:58:11

I always seem to have this internal struggle when it comes to user interface. I build up an application "engine" and tend to defer user interface to after I get my algorithms working. Then I go back and forth trying to decide how to let a user interact with my program. Personally, I'm a fan of the command line, but I can't expect that of my users generally.

在用户界面方面,我似乎总是有这种内心的挣扎。我构建了一个应用程序“引擎”,并倾向于在我的算法工作后将用户界面推迟到。然后我来来回回地试图决定如何让用户与我的程序交互。就我个人而言,我是命令行的粉丝,但我不能期望我的用户一般都是这样。

I really like what's possible in the browser in the age of web 2.0 and ajax. On the other hand it's not so hard to make a Swing front-end either, and you can generally count on a more consistent presentation to the user (though using a good javascript framework like YUI or jQuery goes a long way toward normalizing browsers).

我非常喜欢web 2.0和ajax时代的浏览器。另一方面,制作Swing前端也不是那么困难,而且您通常可以依赖于对用户的更一致的表示(尽管使用YUI或jQuery这样的优秀javascript框架有助于实现浏览器的规范化)。

Clearly both approaches have their merits and drawbacks. So, what criteria / parameters / situations should lead me to use a lightweight (e.g. web-based) GUI? What criteria / parameters / situations should lead me to use a heavier (e.g. Swing-based) GUI?

显然,这两种方法都有各自的优缺点。那么,什么标准/参数/情况应该引导我使用轻量级(例如基于web的)GUI?什么标准/参数/情况应该让我使用更重的GUI(例如基于swing的GUI) ?

It is not my intent to start a flame war, merely interested in the community's constructive/objective opinions.

我无意挑起一场激烈的战争,而只是对社区的建设性/客观意见感兴趣。

Edit #1 In light of the first few responses, I would like to clarify that I would like to deploy my application regardless, not host it on some internet server necessarily. So I would have to deploy with a light-weight web-server infrastructure a la Jetty/Tomcat or similar.

编辑#1根据前面的几个响应,我想澄清一点,我无论如何都希望部署我的应用程序,而不是一定要在某些internet服务器上托管它。因此,我必须使用轻量级的web服务器基础结构来部署Jetty/Tomcat或类似的东西。

8 个解决方案

#1


2  

It depends on the application and this is essentially a usability driven question (though there are considerations like data storage and platform requirements). Think of the pros and cons.

它取决于应用程序,这本质上是一个可用性驱动的问题(尽管有一些考虑,比如数据存储和平台需求)。考虑一下利弊。

Pros of a lightweight Web UI:

轻量级Web UI的优点:

  • Ease of distribution
  • 易于分布
  • Platform independent
  • 平台无关的
  • Ease of maintenance
  • 易于维护

Cons of a lightweight Web UI:

轻量级Web UI的缺点:

  • Less environmental control
  • 更少的环境控制
  • Markup standards vary between browsers
  • 不同浏览器的标记标准不同
  • Requires a web server and everything that goes with it
  • 需要一个web服务器以及与之相关的所有东西

Pros of an executable UI

可执行UI的优点

  • More environmental control (i.e.: full screen applications, etc)
  • 更多的环境控制(即。:全屏应用等)
  • Not necessarily subject to latency and outages
  • 不一定要受延迟和中断的影响。

Cons of an executable UI

可执行UI的缺点

  • Pushing updates may be more difficult
  • 推动更新可能会更加困难。
  • Requires installation
  • 需要安装
  • Potential platform requirements (frameworks, packages, etc)
  • 潜在的平台需求(框架、包等)
  • Potentially requires knowledge of advanced networking topics (web services, etc)
  • 可能需要了解高级网络主题(web服务等)

#2


1  

One small factor you may want to consider is that the user will have go through some type of installation (albeit minimal) if you distribute a swing application.

您可能需要考虑的一个小因素是,如果您发布swing应用程序,用户将会经历某种类型的安装(尽管是最少的)。

Also a web application will allow you to accurately track the usage of your application (via google analytics or something similar). Not sure if that's a concern but it may be useful to you in the future.

此外,web应用程序还允许您精确地跟踪应用程序的使用情况(通过谷歌分析或类似的方法)。我不确定这是否是一个问题,但它可能在未来对你有用。

#3


1  

If it is a client-server application I would normally go for a web frontend for the application.

如果是客户机-服务器应用程序,我通常会选择web前端应用程序。

You will save yourself of countless problems with things like installed JRE versions, distributing upgrades, application permissions, disappeared shortcuts...

您将避免安装JRE版本、分发升级、应用程序权限、消失的快捷方式等无数问题。

#4


1  

You need to break the requirements of the application down to decide this...

您需要打破应用程序的要求来决定……

  1. Do the users have Java of sufficient version installed? It will need to be, to run a Swing GUI.
  2. 用户是否安装了足够版本的Java ?它需要运行Swing GUI。
  3. Do you have a web server?
  4. 你有网络服务器吗?
  5. Do you need the flexibility of a Swing GUI or the accessibility of the web interface?
  6. 您需要Swing GUI的灵活性还是web界面的可访问性?
  7. Is Java Webstart and option, if so, you can distribute a Swing GUI via the web.
  8. 是Java Webstart和option,如果是,您可以通过web分发Swing GUI。
  9. Does your application perform extensive calculations or processing? If so, a client app may be the answer.
  10. 应用程序是否执行广泛的计算或处理?如果是的话,客户端应用程序可能是答案。

There are a million questions such as these. I would suggest a brain storming session and keeping track of all the pros and cons of each, adding a point score, than throwing it all away and going with your gut feeling :)

有无数这样的问题。我建议你进行一次头脑风暴会议,记录下每一个人的利弊,加一个分数,而不是把它们都扔到一边,凭直觉去做:

#5


0  

If you anticipate there being frequent updates to the app then web based may be better since the user would not have to update the client or install a new client containing the updates. If you think that the user may need the ability to use the app while not conencted to the internet then swing would be better.

如果您预期应用程序会经常更新,那么基于web的可能会更好,因为用户不必更新客户机或安装包含更新的新客户机。如果您认为用户可能需要使用该应用程序的能力,而不受internet限制,那么swing将会更好。

Just two things off the top of my head.

我脑子里只有两件事。

#6


0  

Think about the users and use cases of your project.

考虑项目的用户和用例。

Do users expect to have access to it when they're disconnected from the Internet (for example, on an airplane or in a coffee shop with no Internet access)? Use Swing.

当用户与互联网断开连接时(例如,在飞机上或在没有互联网接入的咖啡店),他们是否希望能够访问它?使用Swing。

Do you want users to be able to access the same tool from different computers (for example, both at work and at home)? Use a web UI.

您希望用户能够从不同的计算机(例如,在工作和家庭中)访问相同的工具吗?使用web UI。

Also consider whether the user needs to save and load data, and whether the tool produces data files that some might consider sensitive (if so, storage on the web might be an issue).

还要考虑用户是否需要保存和加载数据,以及该工具是否生成一些人可能认为敏感的数据文件(如果有,web上的存储可能是一个问题)。

#7


0  

Do make a quick guess I often try to ask myself/customers if the application has a high "write" demand. For a mostly read-only application a thin-client solution is perfectly well suited. But if a lot write actions are needed then a swing desktop application has more flexibility.

我经常试着问我自己/客户,这个应用程序是否有很高的“写”要求。对于只读的应用程序,瘦客户机解决方案非常适合。但是,如果需要大量的写操作,那么swing桌面应用程序就具有更大的灵活性。

Personally I always prever a swing desktop application. It can easily deployed using Java Webstart.

就我个人而言,我总是准备一个swing桌面应用程序。它可以使用Java Webstart轻松部署。

#8


0  

Not knowing anything about your application I can not give the best recommendation possible. However I can state from personal/professional experience that installing an application on clients machines is a LOT more of a pain in the ass than it seems.

我对你的申请一无所知,所以不能给你最好的建议。然而,根据我的个人/专业经验,在客户端机器上安装应用程序比看上去要麻烦得多。

With AJAX/web you really only have to worry about supporting like three browsers. Installation messes/updates are only felt once when you deploy the product to the web server.

使用AJAX/web,你只需要考虑支持三个浏览器。当您将产品部署到web服务器时,只会感觉到一次安装混乱/更新。

With like a stand-along Swing app, you get to deal with the really really big mess that is installing the application onto unknown systems. This mess was so bad that things like AJAX were really pushed along to make web apps behave/feel like a real native app.

使用一个备用的Swing应用程序,您可以处理真正的大问题,即将应用程序安装到未知的系统上。这种混乱是如此的糟糕,以至于像AJAX这样的东西真的被推来推去,让web应用程序表现得像一个真正的本地应用程序。

#1


2  

It depends on the application and this is essentially a usability driven question (though there are considerations like data storage and platform requirements). Think of the pros and cons.

它取决于应用程序,这本质上是一个可用性驱动的问题(尽管有一些考虑,比如数据存储和平台需求)。考虑一下利弊。

Pros of a lightweight Web UI:

轻量级Web UI的优点:

  • Ease of distribution
  • 易于分布
  • Platform independent
  • 平台无关的
  • Ease of maintenance
  • 易于维护

Cons of a lightweight Web UI:

轻量级Web UI的缺点:

  • Less environmental control
  • 更少的环境控制
  • Markup standards vary between browsers
  • 不同浏览器的标记标准不同
  • Requires a web server and everything that goes with it
  • 需要一个web服务器以及与之相关的所有东西

Pros of an executable UI

可执行UI的优点

  • More environmental control (i.e.: full screen applications, etc)
  • 更多的环境控制(即。:全屏应用等)
  • Not necessarily subject to latency and outages
  • 不一定要受延迟和中断的影响。

Cons of an executable UI

可执行UI的缺点

  • Pushing updates may be more difficult
  • 推动更新可能会更加困难。
  • Requires installation
  • 需要安装
  • Potential platform requirements (frameworks, packages, etc)
  • 潜在的平台需求(框架、包等)
  • Potentially requires knowledge of advanced networking topics (web services, etc)
  • 可能需要了解高级网络主题(web服务等)

#2


1  

One small factor you may want to consider is that the user will have go through some type of installation (albeit minimal) if you distribute a swing application.

您可能需要考虑的一个小因素是,如果您发布swing应用程序,用户将会经历某种类型的安装(尽管是最少的)。

Also a web application will allow you to accurately track the usage of your application (via google analytics or something similar). Not sure if that's a concern but it may be useful to you in the future.

此外,web应用程序还允许您精确地跟踪应用程序的使用情况(通过谷歌分析或类似的方法)。我不确定这是否是一个问题,但它可能在未来对你有用。

#3


1  

If it is a client-server application I would normally go for a web frontend for the application.

如果是客户机-服务器应用程序,我通常会选择web前端应用程序。

You will save yourself of countless problems with things like installed JRE versions, distributing upgrades, application permissions, disappeared shortcuts...

您将避免安装JRE版本、分发升级、应用程序权限、消失的快捷方式等无数问题。

#4


1  

You need to break the requirements of the application down to decide this...

您需要打破应用程序的要求来决定……

  1. Do the users have Java of sufficient version installed? It will need to be, to run a Swing GUI.
  2. 用户是否安装了足够版本的Java ?它需要运行Swing GUI。
  3. Do you have a web server?
  4. 你有网络服务器吗?
  5. Do you need the flexibility of a Swing GUI or the accessibility of the web interface?
  6. 您需要Swing GUI的灵活性还是web界面的可访问性?
  7. Is Java Webstart and option, if so, you can distribute a Swing GUI via the web.
  8. 是Java Webstart和option,如果是,您可以通过web分发Swing GUI。
  9. Does your application perform extensive calculations or processing? If so, a client app may be the answer.
  10. 应用程序是否执行广泛的计算或处理?如果是的话,客户端应用程序可能是答案。

There are a million questions such as these. I would suggest a brain storming session and keeping track of all the pros and cons of each, adding a point score, than throwing it all away and going with your gut feeling :)

有无数这样的问题。我建议你进行一次头脑风暴会议,记录下每一个人的利弊,加一个分数,而不是把它们都扔到一边,凭直觉去做:

#5


0  

If you anticipate there being frequent updates to the app then web based may be better since the user would not have to update the client or install a new client containing the updates. If you think that the user may need the ability to use the app while not conencted to the internet then swing would be better.

如果您预期应用程序会经常更新,那么基于web的可能会更好,因为用户不必更新客户机或安装包含更新的新客户机。如果您认为用户可能需要使用该应用程序的能力,而不受internet限制,那么swing将会更好。

Just two things off the top of my head.

我脑子里只有两件事。

#6


0  

Think about the users and use cases of your project.

考虑项目的用户和用例。

Do users expect to have access to it when they're disconnected from the Internet (for example, on an airplane or in a coffee shop with no Internet access)? Use Swing.

当用户与互联网断开连接时(例如,在飞机上或在没有互联网接入的咖啡店),他们是否希望能够访问它?使用Swing。

Do you want users to be able to access the same tool from different computers (for example, both at work and at home)? Use a web UI.

您希望用户能够从不同的计算机(例如,在工作和家庭中)访问相同的工具吗?使用web UI。

Also consider whether the user needs to save and load data, and whether the tool produces data files that some might consider sensitive (if so, storage on the web might be an issue).

还要考虑用户是否需要保存和加载数据,以及该工具是否生成一些人可能认为敏感的数据文件(如果有,web上的存储可能是一个问题)。

#7


0  

Do make a quick guess I often try to ask myself/customers if the application has a high "write" demand. For a mostly read-only application a thin-client solution is perfectly well suited. But if a lot write actions are needed then a swing desktop application has more flexibility.

我经常试着问我自己/客户,这个应用程序是否有很高的“写”要求。对于只读的应用程序,瘦客户机解决方案非常适合。但是,如果需要大量的写操作,那么swing桌面应用程序就具有更大的灵活性。

Personally I always prever a swing desktop application. It can easily deployed using Java Webstart.

就我个人而言,我总是准备一个swing桌面应用程序。它可以使用Java Webstart轻松部署。

#8


0  

Not knowing anything about your application I can not give the best recommendation possible. However I can state from personal/professional experience that installing an application on clients machines is a LOT more of a pain in the ass than it seems.

我对你的申请一无所知,所以不能给你最好的建议。然而,根据我的个人/专业经验,在客户端机器上安装应用程序比看上去要麻烦得多。

With AJAX/web you really only have to worry about supporting like three browsers. Installation messes/updates are only felt once when you deploy the product to the web server.

使用AJAX/web,你只需要考虑支持三个浏览器。当您将产品部署到web服务器时,只会感觉到一次安装混乱/更新。

With like a stand-along Swing app, you get to deal with the really really big mess that is installing the application onto unknown systems. This mess was so bad that things like AJAX were really pushed along to make web apps behave/feel like a real native app.

使用一个备用的Swing应用程序,您可以处理真正的大问题,即将应用程序安装到未知的系统上。这种混乱是如此的糟糕,以至于像AJAX这样的东西真的被推来推去,让web应用程序表现得像一个真正的本地应用程序。