Scala Lift 接线能给我带来什么?

发布于 2024-10-10 20:36:32 字数 79 浏览 1 评论 0原文

我一直在研究 Scala Web 框架 Lift。我最近看到了一种叫做“接线”的东西,想知道是否有人可以向我(作为应用程序程序员)解释它的好处。

I have been looking at the Scala web framework Lift. I recently saw something called Wiring and was wondering if someone could explain the benefits to me, as an application programmer.

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

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

发布评论

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

评论(4

叹沉浮 2024-10-17 20:36:32

连接使您能够声明 HTML 页面上不同元素之间的关系,并且当谓词值发生变化时,相关值将在页面上自动更新。

想想电子表格和 Java/Scala 程序之间的区别。在电子表格中,您可以声明单元格之间复杂的相互关系,并且当谓词更改时,单元格会自动更新。即使编写一个反映非常简单的电子表格的程序,通常也会运行数百或数千行,并且非常难以维护。

一个具体的例子是购物车。想想当您将商品放入购物车时必须更新的网页的所有部分。编写初始屏幕可能并不难,但请考虑维护的复杂性(好吧,当购物车中添加或删除某些东西时,邮政编码发生变化等时,我必须更新什么)

接线为您提供的是声明关系的能力,无论谓词如何变化(例如,税收规则根据邮政编码而变化,但当税收规则发生变化时,依赖于应税小计的任何内容都会更新),开发人员不必了解所有依赖项也必须更新。

Wiring gives you the ability to declare relationships among different elements on an HTML page and as predicate values change, the dependent values will automatically be updated on the page.

Think about the difference between a spreadsheet and a Java/Scala program. In a spreadsheet, you can declare complex inter-relationships among cells and when predicates change, the cells automatically update. Writing a program that reflects even a pretty simple spreadsheet will typically run into the hundreds or thousands of lines and be very difficult to maintain.

A concrete example is a shopping cart. Think of all the pieces of a web page that must be updated when you put something in a shopping cart. Writing the initial screen may not be hard, but then think about the maintenance complexity (okay, what do I have to update when something gets added to or removed from the cart, when the zip code changes, etc.)

What wiring gives you is the ability to declare relationships and no matter how the predicates change (e.g., tax rules change based on zip code, but anything that depends on taxable subtotal is updated when the tax rules change), the developer doesn't have to understand all the dependents that must also be updated.

梦一生花开无言 2024-10-17 20:36:32

连线(请参阅演示)可以让多个输入字段(或单元格)相互依赖并具有结果自动传递到相关单元格。 – 所有这一切都以一种非常声明性的方式不需要一行 JavaScript。

正如您在演示中看到的,您所做的就是声明单元格如何相互依赖以及它们如何显示。无需编写或调用任何辅助函数即可连接单元。

Wiring (see demo) makes it possible to have several input fields (or cells) depend on each other and have results automatically passed to dependent cells. – And all of that without a line of JavaScript in a very declarative way.

As you can see in the demo, all you do is declaring how the cells depend on each other and then how they are being displayed. No need to write or call any helper functions in order to connect the cells.

南七夏 2024-10-17 20:36:32

您是否阅读了 Lift 邮件列表上有关接线的公告?
https://groups.google.com/forum/# !searchin/liftweb/wiring/liftweb/WwLuiK3x0K4/e44Rm1325p4J

这两个演示也应该有所帮助:
http://demo.liftweb.net/simple_wiring

http://demo.liftweb.net/invoice_wiring

我了解 StackOverflow 的吸引力,但邮件列表是有关 Lift 的信息金矿。

Did you read the announcement on the Lift mailing list about wiring?
https://groups.google.com/forum/#!searchin/liftweb/wiring/liftweb/WwLuiK3x0K4/e44Rm1325p4J

Also the two demos should help:
http://demo.liftweb.net/simple_wiring
and
http://demo.liftweb.net/invoice_wiring

I understand the appeal of StackOverflow, but the mailing list is a goldmine of info about Lift.

慈悲佛祖 2024-10-17 20:36:32

您可能还想查看reactive-web (http://reactive-web.tk),因为它添加了相同的功能以更强大的方式提升。

You may also want to check out reactive-web (http://reactive-web.tk) as it adds the same features to Lift in a much more powerful way.

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