Web 应用程序框架的独特功能

发布于 2024-07-27 20:35:06 字数 842 浏览 9 评论 0 原文

有很多基于 Java/Ruby/Python/PHP 等的Web 应用程序框架。 我热衷于发现、比较和对比各个框架独有的功能。

您认为哪些框架功能有用?为什么了解它很重要?

例如

能否将每个帖子限制为一个功能。

摘要:

  • Stripes - Flash范围
  • Django - 模板中的 JSON 化变量
  • Symfony - 模型生成。 后端管理生成
  • 形式的强大 ORM
  • Grails - GORM Seaside
  • - 没有关系数据库,只需代码 OO Sinatra - 极简主义
  • Spring Web Flow - 流程和视图范围

There are a lot of web application frameworks out there, based in Java/Ruby/Python/PHP amongst others. I'm keen to discover, compare and contrast features that are unique to individual frameworks.

Which framework feature do you think is useful and why is it important to know about?

e.g.

Can you please limit to one feature per post.

Summary:

  • Stripes - Flash Scope
  • Django - JSONified variables in templates
  • Symfony - model generation. Backend administration generation
  • Grails - Powerful ORM in the form of GORM
  • Seaside - no relational database, just code OO
  • Sinatra - Minimalism
  • Spring Web Flow - Flow and view scope

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

抽个烟儿 2024-08-03 20:35:06

替代文本
(来源:symfony-project.org

Symfony 在 PHP 框架方面做了一些非常独特的事情。

我认为其中一些功能在其他地方使用,但我认为它们在 PHP 中是独一无二的。

alt text
(source: symfony-project.org)

Symfony does some quite unique things in regards to PHP frameworks.

I presume some of these features are used elsewhere, but I think that within PHP they are unique.

诺曦 2024-08-03 20:35:06

Sinatra 的极简主义。 您可以在一个文件中编写整个 Web 应用程序。 (显然,这对于大型应用程序来说是行不通的,但对于快速原型设计、小型站点和 Web 服务来说,将所有内容都集中在一处是很棒的。)

Minimalism of Sinatra. You can write entire web application in only one file. (Obviously, this is no way for large applications, but for rapid prototyping, small sites and web services it's great to have everything in one place.)

狼性发作 2024-08-03 20:35:06

Grails http://www.cjsdn.net/JVM/Grails /Docs/1.1/img/grails.png

GORM - 我还没有见过另一个框架具有如此强大的 ORM 但又如此易于使用。

Grails http://www.cjsdn.net/JVM/Grails/Docs/1.1/img/grails.png

GORM - I have not seen another framework with such a powerful ORM yet so easy to use.

我还不会笑 2024-08-03 20:35:06

Django 的内置管理 就采用而言可能是其杀手级功能。 编写您的数据库模型,注册它们,然后开始输入数据。 如果需要的话可以定制。 它非常简单,我一直在非 django 项目中使用它。

Django's built-in admin is probably its killer feature as far as adoption is concerned. Write your db models, register them, and start entering data. Customize if needed. It's easy enough that I use it on non-django projects all the time.

宣告ˉ结束 2024-08-03 20:35:06

您应该知道如何在 Django 中编写自定义模板标签。 例如,以下标签允许我在模板中对 Django 变量进行 JSONify。

@register.filter
def jsonify(o):
  return mark_safe(simplejson.dumps(o))

这很有用,因为我的网站都是 Javascript,所以我也使用 Django 模板制作该网站的无脚本版本。 这非常有用,因此 Google 可以抓取我的网站。 例如,查看以下打开和关闭 Javascript 的页面: http://www.trailbehind .com/Yosemite%20National%20Park/

这是我拥有的其他一些有用的标签:

@register.filter
def attr_name(id):
  return util.get_attribute(id).name


@register.filter
def dashes(name):
  return name.replace(' ', '-')

Python 的装饰器语法不是让这些标签变得简短而甜蜜吗?

You should know how to write custom template tags in Django. For example, the following tag lets me JSONify Django variables in the template.

@register.filter
def jsonify(o):
  return mark_safe(simplejson.dumps(o))

This is useful because my website is all Javascript, so I use the Django templates to make a no-script version of the site as well. This is mostly useful so Google can crawl my site. For example, look at the following page with Javascript on and off: http://www.trailbehind.com/Yosemite%20National%20Park/

Here's some other useful tags I have:

@register.filter
def attr_name(id):
  return util.get_attribute(id).name


@register.filter
def dashes(name):
  return name.replace(' ', '-')

And doesn't Python's decorator syntax make these short and sweet?

丶视觉 2024-08-03 20:35:06

Seaside,不必费心使用关系数据库(SandstoneDB、Magma 或 Gemstone),允许通过某些方法编写 OO 代码而不是数据库代码。

Seaside, not having to bother with a relational database (SandstoneDB, Magma or Gemstone), allows the writing of OO code instead of database code with some methods.

剧终人散尽 2024-08-03 20:35:06

Smalltalk 中的 Seaside 支持重构和 goto-less 编程。 基于组件且无模板意味着您可以避免大量重复。

Seaside in Smalltalk supports refactoring and goto-less programming. Component based and no templates means you can avoid a lot of duplication.

白色秋天 2024-08-03 20:35:06

Spring Web Flow - 序列化对话/出色的浏览器后退按钮支持

支持浏览器后退按钮和历史记录是一个令人头痛的问题对于大多数网络应用程序来说,仅仅是因为客户端感知的状态/页面很容易与服务器上的内容不同步。

SWF 通过在每次呈现视图时创建整个对话状态的快照来解决此问题。 大多数状态数据存储在 SWF 的附加范围之一(对话、流、视图)中,因此与对话快照一起序列化。

SWF 的 URL 不标识页面或操作等资源。 相反,他们识别流程和对话。 由于 SWF 隐式实现 POST-REDIRECT-GET,因此每次呈现页面时,URL 都包含 flowExecutionId,它唯一标识会话和序列化会话快照。 因此,当用户使用浏览器后退按钮或历史记录时,每个 URL 实际上会及时恢复该时间点的整个对话状态。

这会产生理想的后退按钮处理:客户端状态永远不会与对话状态不同步,并且用户可以自由地从任何先前状态继续。

当用户执行某些操作时,开发人员还可以丢弃历史记录(保存的快照)或使其无效。 这对于修改数据库中某些内容的用户操作很有用,因为用户不应该能够返回到不代表数据库中内容的状态。

开发人员可以精确限制要保存的快照数量。 由于硬盘驱动器容量充足,尤其是与内存相比,因此这是一个相当简洁的解决方案。

然而,一个主要限制是,放置在对话、流或视图范围中的任何属性都必须是可序列化的。

Spring Web Flow - Serialized conversations / great browser back button support

Supporting the browser back button and history is a headache with most web apps out there, simply because it's too easy for the client's perceived state / page to get out of sync with what's on the server.

SWF solves this by creating snapshots of the entire conversation state each time a view is rendered. Most stateful data is stored in one of SWF's additional scopes (conversation, flow, view), and is thus serialized with the conversation snapshot.

SWF's URLs don't identify a resource like a page or an action. Instead, they identify a flow and a conversation. Since SWF implements POST-REDIRECT-GET implicitly, each time a page is rendered the URL contains the flowExecutionId, which uniquely identifies the conversation and the serialized conversation snapshot. Thus, as the user uses the browser back button or history, each URL actually restores the entire conversation state at that point in time.

This results in ideal back button handling: client state is never out of sync with conversation state, and the user can freely continue from any previous state.

Developers can also discard or invalidate history (saved snapshots) when users perform certain actions. This is good for user actions which modify something in the database, since the user should not have the ability to go back to a state which doesn't represent what's in the database.

The developer can restrict exactly how many snapshots to save. Since hard drive capacity is plentiful, especially in comparison to memory, it's a fairly neat solution.

One major restriction, however, is that any attribute placed in conversation, flow, or view scope must be Serializable.

世界等同你 2024-08-03 20:35:06

Spring Web Flow - 流程和视图范围

大多数 Web 应用程序都满足于使用 Servlet 定义的请求范围,会话和上下文。 然而,Web 应用程序中使用的大部分状态数据并不完全适合这些范围。 通常,此类数据的持续时间比单个请求长,但比会话短。 在这种情况下通常使用会话范围。 这迫使开发人员本质上执行手动内存管理,将事物放入会话范围内,然后在应用程序的该部分不再需要它们时显式删除它们。 这可能会很麻烦,因为通常有多个位置必须删除属性,因为用户通常可以调用多个操作来将它们从需要属性的用例中删除。

在大型或不断增长的应用程序中,属性清理代码成为整个代码中必要且普遍的混乱。 忘记清理属性或错误地清理错误的属性可能会引入错误。

SWF 通过提供一些更适合应用程序属性生命周期的附加范围来解决此问题。

SWF 引入了流的概念,流是可重用的行为模块化分组,表示为由状态和状态之间的转换组成的状态机。 流程可以包括用于调用服务器端行为的动作状态、用于向用户呈现页面的视图状态等。 流程通常代表用例。 流范围的属性在流的持续时间内持续存在,并在流结束时自动清除。 这导致属性仅在需要它们的用例持续时间内持续存在。

流中的视图状态向用户呈现视图。 从 viewState 进行的转换可以导航到不同的状态,也可以保留在相同的 viewState 中,在执行某些操作后重新呈现视图(使用或不使用 AJAX)。 当控制权保留在 viewState 中时,viewScope 中的属性仍然存在。 ViewScoped 属性在浏览器刷新后仍然存在,并且对于仅与正在呈现的视图相关的数据很有用,例如 AJAX 请求中使用的数据,或以某种方式影响标记的标志。 当调用离开 viewState 的转换时,viewScoped 属性将被清除。

总之,SWF 的附加作用域更适合应用程序属性的生命周期,并且使用这些附加作用域无需手动管理属性,从而减少整个应用程序中属性杂乱的管道代码,并减少出现错误的可能性。

Spring Web Flow - Flow and view scope

Most web apps are content to use the Servlet defined scopes of request, session, and context. However, much of the stateful data used in a web app doesn't quite fit into any of these scopes. Typically, such data lasts longer than a single request, but shorter than a session. Session scope is usually used in this case. This forces the developer to essentially perform manual memory management to place things into session scope, and then explicitly remove them when they are no longer needed for that portion of the application. This can be troublesome, as there are usually multiple places where attributes must be removed, as there are often several actions that the user can invoke to take them out of the use case where the attributes are needed.

In large or growing applications, attribute cleanup code becomes a necessary and pervasive clutter throughout the code. Forgetting to clean up attributes, or cleaning up the wrong ones by mistake, can introduce bugs.

SWF solves this by providing some additional scopes which better fit the life cycle of application attributes.

SWF introduces the concepts of flows, which are reusable modular groupings of behavior represented as a state machine consisting of states and transitions between them. A flow may include action-states for invoking server-side behavior, view-states for rendering pages to the user, and others. Flows often represent use cases. Flow-scoped attributes persist for the duration of the flow, and are cleaned up automatically when the flow ends. This results in attributes which only persist for the duration of the use case where they are needed.

ViewStates within a flow render a view to the user. Transitions from a viewState may navigate to a different state or can remain in the same viewState, rerendering the view (with or without AJAX) after performing some actions. Attributes in viewScope persist while control remains in the viewState. ViewScoped attributes survive browser refreshes, and are useful for data that is relevant only for the view being rendered, such as data which is used in AJAX requests, or for flags which influence the markup in some way. When a transition is invoked which leaves the viewState, viewScoped attributes are cleaned up.

In summary, SWF's additional scopes better fit the lifecycle of application attributes, and using these additional scopes removes the need to manually manage your attributes, resulting in less attribute-juggling plumbing code throughout your app and less potential for bugs.

骄兵必败 2024-08-03 20:35:06

CakePHP Logo

CakePHP 显着功能:

  • bake 工具可自动从数据库创建模型和控制器
  • 零配置 - 你只需要设置一个数据库连接,就可以开始
  • 脚手架 - 你甚至不需要生成视图,cake 会为你生成
  • 很多帮助程序 - AJAX、JavaScript、HTML、表单、分页、XML、RSS,只要你能想到的
  • ActiveRecord
  • 用于单元测试
  • 数据验证的 SimpleTest - 易于使用,但强大的
  • 数据清理功能 - 不用担心代码注入
  • 路由器 - 允许您将“自定义”URL 重定向到特定的控制器/操作

摘要:许多人认为 Cake 对于 PHP 来说就像 Rails 对于 Ruby 一样。

CakePHP Logo

CakePHP notable features:

  • bake tool to create models and controllers from your database automatically
  • zero-config - you just need to set up a database connection and you are good to go
  • scaffolding - you don't even need to generate your views, cake will generate them for you
  • lots of helpers - AJAX, JavaScript, HTML, Forms, Pagination, XML, RSS, you name it
  • ActiveRecord
  • SimpleTest for unit testing
  • data validation - easy to use, yet powerful
  • data sanitization - less worrying about code injection
  • router - allows you to redirect your 'custom' URLs to specific controllers/actions

Summary: many people thinks that Cake is for PHP the same as Rails are for Ruby.

深海里的那抹蓝 2024-08-03 20:35:06

嗯...我是一名 PHP 开发人员,已有大约 15 年的经验。 看看Rails(Ruby on Rails)框架。 它具有一些独特的功能,例如数据库迁移,接口的实现不同于Java、PHP等语言,配置文件不像ini文件(您可以编写代码)。

希望能帮助到你。

Hum... I am a PHP developer for about 15 years. Look at Rails (Ruby on Rails) framework. It has some unique features like database migrations, implementation of interfaces differs from languages like Java, PHP and others, configuration files are not like ini files (you can write code).

Hope it helps.

左岸枫 2024-08-03 20:35:06

Zend Framework

Zend Framework 具有以下显着功能:

  • 选择您使用的内容。 ZF 是轻量级松耦合组件的集合。
  • Google亚马逊雅虎!Flickr 和其他几个 API
  • 易于使用 XML-RPC、SOAP 和 REST 服务器/客户端
  • 与 Adob​​e AIR 和 Adob​​e AIR 集成 Flex
  • Zend_CodeGenerator
  • 内置 DB、LDAP 和 OpenID 身份验证
  • DojojQuery
  • 一个适合企业应用程序的框架(FOX、IBM、Right Media)
  • 一个非常活跃的社区(irc.freenode.net 上的#zftalk)
  • 不会创建你的模型。 (这是一件好事)。

Zend Framework

Zend Framework has the following notable features:

  • Pick and choose what you use. ZF is a collection of lightweight loosely-coupled components.
  • Integration with Google, Amazon, Yahoo!,Flickr, and several other APIs
  • Easy to use XML-RPC, SOAP, and REST server/clients
  • Integration with Adobe AIR & Flex
  • Zend_CodeGenerator
  • Built-in DB, LDAP, & OpenID authentication
  • Great integration with Dojo and jQuery
  • A framework suitable for enterprise applications (FOX, IBM, Right Media)
  • A very active community (#zftalk on irc.freenode.net)
  • It doesn't create your model. (Which is a good thing).
猫性小仙女 2024-08-03 20:35:06

Icefaces 拥有强大的可扩展ajax推送框架

Icefaces has a powerful scalable ajax push framework

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文