基于 Java 组件与基于请求的框架 [英] Java Component based vs Request based frameworks

查看:28
本文介绍了基于 Java 组件与基于请求的框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在一次采访中被问到 - 在 java 中,您如何比较基于组件的框架和基于请求的框架?我将 EJB 解释为基于组件的框架的示例,将 Struts 解释为基于请求的框架,但我不相信我是否公正地回答了这个问题.

I was recently asked in an interview - In java, how do you compare component based frameworks to request based frameworks? I explained EJB as an example of Component based framework and Struts as a request based framework but was not convinced if I did justice to the question.

对于面试官的意思和应该比较的内容有什么想法吗?

Any ideas on what interviewer meant and what should have been compared??

问候,阿瓦朱鲁格

推荐答案

他们最有可能在寻找 web 框架的示例 - 例如,JSF 是基于组件的框架,而 Struts 是基于请求的框架.

They were most likely looking for examples of web frameworks - for example, JSF is a component-based framework, and Struts is a request-based framework.

基于请求的框架通常通过其 API 清楚地表明它们正在解析 HTML 请求/生成 HTML 响应,而基于组件的框架试图将其抽象出来并将应用程序视为具有渲染器的组件集合和做事的行动.

Request-based frameworks generally make it clear through their APIs that they're working with parsing an HTML request / generating an HTML response, while Component-based frameworks attempt to abstract this away and treat the application as collections of components with renderers and actions to do things.

在我看来,基于组件的 Web 框架比它们的价值要麻烦得多——它们的主要目的通常是让不熟悉 Web 开发的开发人员更容易"开发 Web 应用程序,并且更接近于传统的桌面开发.但是,在实践中,当出现问题时,您需要开发自定义组件,需要为非开箱即用"功能的东西自定义框架等.您需要了解底层的传统"Web 开发基于组件的框架如何对其进行抽象 - 如果您是一位经验丰富的 Web 开发人员并且拥有适用于传统"Web 开发的现有解决方案、实用程序、库或片段,那么您将浪费时间重新实现它们以在基于组件的框架内工作.

In my opinion, component-based web frameworks are more trouble than they're worth - their main purpose is usually to make the development of a web app "easier" for developers unfamiliar with web development, and closer to traditional desktop development. However, in practice, when something goes wrong, you need to develop custom components, you need to customize the framework for something that isn't "out of the box" functionality, etc. you need to understand both underlying "traditional" web development and how the component-based framework abstracts it - and if you're an experienced web developer and have existing solutions, utilities, libraries or snippets that worked in "traditional" web development, you'll waste time re-implementing them to work within the component-based framework.

这篇关于基于 Java 组件与基于请求的框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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