究竟什么是意向编程

发布于 2024-07-07 09:44:10 字数 172 浏览 7 评论 0原文

在我的疯狂阅读中,我偶然发现了一种叫做意向编程的东西。 我明白了一些,但并不完全明白。 如果有人可以更详细地解释它,请这样做。 它是否被用于任何实际应用中?

On my reading spree, I stumbled upon something called Intentional Programming.
I understood it somewhat, but I not fully. If anyone can explain it in better detail, please do. Is it being used in any real application?

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

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

发布评论

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

评论(7

—━☆沉默づ 2024-07-14 09:44:10

你让我开始做这个......
看起来 C. Simonyi 想要从高级语言进入下一个抽象层次。 减少客户对开发人员在代码中进行每项更改的依赖(对于不参与开发的人员来说是神秘的)。
因此,他发明了这个名为 IP 的新产品,它具有所见即所得类型的 GUI 编辑器来创建特定于领域的模型。 (即 IP 有一个 GUI 可以为您的应用程序创建构建块。LISP 允许您创建元/构建块,但不是以领域专家可以轻松完成的方式。)
与 UML 中的模型一样,您可以通过“按一下按钮”自动生成相应的源代码。 因此,领域专家可以在未来调整模型并按下“烘焙”按钮来交付应用程序的下一个版本。
它似乎利用了 DSL,但是还有一个额外的好处,多个用户创建的 DSL 可以通过内置的 IP 机制相互通信...这意味着财务模型和销售模型可以交互和重用根据需要进行块。 与 DSL 一样,您可以从代码中受益,这些代码可以传达开发人员的意图,而不是满足实现语言的限制。

这个想法是为真正知道需要什么的 BA 和领域专家提供更大的控制权......

更新
现实世界的使用看起来“还没有”..尽管西蒙尼相信“绝对是长期的术语'。
短篇故事:微软为了支持.Net框架而压制了IP,Simonyi离开微软并成立了自己的公司'

来源:

直到昨天才想到。我对此一无所知。 调查记者签字。 回到日常工作:)

You got me started on this one...
Looks like C. Simonyi wanted to step to the next level of abstraction from High level languages. Reduce the dependency of customers on developers to make every change.. in code (cryptic for people not in development).
So he invents this new product called IP, which has a WYSIWYG type GUI editor to create a domain specific model. (i.e. IP has a GUI to create the building blocks for your app.. LISP allowed you to create the meta/building blocks but not in a way that domain experts could easily do it.)
Like the models in UML, the promise is that you can auto-generate the corresponding source code at the "push of a button". So the domain experts can tweak the model in the future and press the Bake button to deliver the next version of the app.
It seems to utilise DSLs however with the added benefit that multiple user-created DSLs can talk with each other via a built-in IP mechanism... which means the finance model and sales model can interact and reuse blocks as needed. As with DSLs, you get the benefit of code that conveys developer intent rather than appeases implementation language constraints.

The idea being to give greater control to the BA and domain experts who actually know what's needed...

Update:
Real world use looks like 'not yet'.. although Simonyi believes 'absolutely in the long term'.
Short Story: MS squished IP in favor of .Net framework, Simonyi left MS and formed his own company 'Intentional Software'.. with the contract that he could use the IP ideas but he would have to rewrite his working proto from the ground up.. (that should slow him down). It's still Work-In-Progress I think.. and being written in C# (to boot)

Sources:

To think till yesterday.. I didn't know a thing about this. Investigative reporter signing off. Going back to day job :)

小瓶盖 2024-07-14 09:44:10

发生的情况相反。

这与我在逛酒吧后凌晨 2 点回家并启动笔记本电脑“只是为了快速查看我的电子邮件,亲爱的。”然后,第二天,当我打开笔记本电脑时 一只眼睛找到了去卫生间的中午,我开始刷牙,牙膏从我嘴里流出来,我意识到昨晚我刷了 4 个牙膏SVN 提交,关闭了 3 个 bug,并找出了如何解决我们的分布式锁定协议上的饥饿问题。 我已经不知道它到底是如何工作的了。

或者也许这就是workmad3所说的。

It's the opposite of what happens when I come home at 2am after a pub crawl and fire up the laptop "just to check my email real quick, hon."

Then, the next day, when I peel open one eye and find my way to the bathroom at the crack of noon, I start brushing my teeth and realize, toothpaste dribbling out of my mouth, that last night I made 4 SVN commits, closed 3 bugs, and figured out how to solve the starvation problem on our distributed locking protocol. And I have no idea how the hell any of it works, anymore.

Or maybe it's what workmad3 said.

猫七 2024-07-14 09:44:10

它似乎是一种编程方法,允许程序员扩展语言中的实际内容,以更紧密地遵循其原始意图,而不是将程序员的意图强加于语言的受限语法中。

它明确提到 LISP 作为支持此功能的语言,因此我建议您阅读这种出色的语言 :) LISP 宏正是本文中描述的内容,允许您无限扩展该语言以涵盖几乎所有您关心的内容表达。 (大型 LISP 系统的一个相当常见的结果是,您最终会得到一种非常适合编写特定应用程序的领域特定语言,即编写一个文字处理程序最终会得到一种文字处理程序特定语言)。

对于您的最后一部分,是的,LISP(以及意向编程)在某些项目中使用。 Paul Graham 是 LISP 的大力支持者,它的其他例子包括最初的 Crash Bandicoot(为此用 LISP 创建了一个游戏对象创建系统,包括一个 LISP PlayStation 编译器)

It appears to be a method of programming that allows the programmer to expand what is actually in the language to more closely follow their original intent, rather than forcing the programmers intent into the constrained syntax of the language.

It explicitly mentions LISP as a language that supports this, so I'd suggest you read up on this great language :) LISP Macros are exactly what are described in the article, allowing you to indefinitely expand the language to cover almost anything you would care to express. (A fairly common outcome of large LISP systems is that you end up with a domain specific language that is very good for writing specific applications, i.e. writing a word processor ends up with a word processor specific language).

For your last part, yes LISP (and thus Intentional Programming) is used in some projects. Paul Graham is a great proponent of LISP, and other examples of it include the original Crash Bandicoot (a game object creation system was created in LISP for this, including a LISP PlayStation compiler)

浮云落日 2024-07-14 09:44:10

我对意向编程的理解略有不同(作为一个更通用的术语,而不仅仅是 Charles Simonyi 正在做的事情)。 它与流畅的界面紧密相连,并且可以用现代面向对象语言以不同程度的难度来实现。

其中一些概念来自领域驱动设计(事实上,术语“流畅的界面”已由 Eric Evans 推广,他是“蓝皮书”的作者 - 领域驱动设计:解决软件核心的复杂性)。

目的是使业务层代码能够被非程序员(即业务人员)可读。 这可以通过明确说明操作意图的类和方法名称来实现。 在我看来,明确且有意地产生高度可读和可维护的代码。

考虑下面的两个示例,它们实现了相同的目的 - 为客户创建一个具有 10% 折扣的订单并向其中添加一些产品。

//C#, Normal version
Customer customer = CustomerService.Get(23);

Order order = new Order();
//What is 0.1? Need to look at Discount property to understand
order.Discount = 0.1; 
order.Customer = customer;

//What's 34?
Product product = ProductService.Get(34); 
//Do we really care about Order stores OrderLines?
order.OrderLines.Add(new OrderLine(product, 1)); 

Product product2 = ProductService.Get(54);
order.OrderLines.Add(new OrderLine(product2, 2)); //What's 2?

Order.Submit();

//C#, Fluent version
//byId is named parameter, states that this method looks up customer by Id
ICustomerForOrderCreation customer = 
  CustomerService.GetCustomerForOrderCreation(byId: 23); 
//Explicit method to create a discount order and explicit percentage
Order order = customer.CreateDiscountOrder(10.Percent()) 
  .WithProduct(ProductService.Get(byId: 34))
  .WithProduct(ProductService.Get(byId: 54))
  .WithQuantity(2); //Explicit quantity

Order.Submit();

通过稍微改变您的编程风格,您可以更清楚地传达您的意图,并减少在其他地方查看代码以了解正在发生的情况的次数。

I have a slightly different understanding of Intentional Programming (as a more general term, not just what Charles Simonyi is doing). It is closely linked to fluent interfaces and can be achieved, with various degrees of difficulty, in modern Object Orientated languages.

Some of these concepts come from Domain Driven Design (in fact the term "fluent interface" has been popularised by Eric Evans, the author of "the" blue book - Domain Driven Design: Tacking Complexity in the Heart of Software).

The aim is to make business layer code readable by a non-programmer (i.e. a business person). This can be achieved by class and method names that explicitly state the intent of the operation. In my opinion, being explicit and being intentional produces highly readable and maintainable code.

Consider the two examples below that achieve the same thing - creating an order for a customer with 10% discount and adding a couple of products to it.

//C#, Normal version
Customer customer = CustomerService.Get(23);

Order order = new Order();
//What is 0.1? Need to look at Discount property to understand
order.Discount = 0.1; 
order.Customer = customer;

//What's 34?
Product product = ProductService.Get(34); 
//Do we really care about Order stores OrderLines?
order.OrderLines.Add(new OrderLine(product, 1)); 

Product product2 = ProductService.Get(54);
order.OrderLines.Add(new OrderLine(product2, 2)); //What's 2?

Order.Submit();

//C#, Fluent version
//byId is named parameter, states that this method looks up customer by Id
ICustomerForOrderCreation customer = 
  CustomerService.GetCustomerForOrderCreation(byId: 23); 
//Explicit method to create a discount order and explicit percentage
Order order = customer.CreateDiscountOrder(10.Percent()) 
  .WithProduct(ProductService.Get(byId: 34))
  .WithProduct(ProductService.Get(byId: 54))
  .WithQuantity(2); //Explicit quantity

Order.Submit();

By changing your programming style slightly, you are able to communicate your intent more clearly and reduce the amount of having to look at code elsewhere to understand what's going on.

北音执念 2024-07-14 09:44:10

在我看来,这就像软件工程的另一种时尚。 我们已经看到了数千种:元编程、生成式编程、可视化编程等等。 在很短的时间内,它们变得非常流行,人们在任何地方都使用它,然后他们总是回到创建软件的旧方法。

为什么? Frederick Brooks 20 多年前就已经回答过这个问题:有 没有一个银弹可以杀死狼人......

Seems to me like yet another fad of software engineering. We've seen thousands of them already: meta programming, generative programming, visual programming, and so on. For a short time they get very fashionable, people use it everywhere, and then they invariably go back to old ways of creating software.

Why? Frederick Brooks has already answered this question over 20 years ago: there's No Single Silver Bullet to kill the werewolf...

多彩岁月 2024-07-14 09:44:10

意向编程正在编码您的意图或目标。 因此,它是面向目标的编程或规划。 加强管理。

Intentional Programming is encoding your intent, or goals. Thus it is Goal-Oriented Programming or Planning. Step up to manangement.

时光无声 2024-07-14 09:44:10

这是您打算编程的地方,而不是无意中进行的。 ;)

It's where you intend to program, you don't just accidently do it. ;)

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