问题描述
我想看看在实际的应用程序/ API中如何使用Builder模式。我发现的示例都是比萨饼,蛋糕,汽车等(加上GoF书中的解析器示例)。
I would like to see how is Builder pattern used in real world applications/APIs. The examples I found are all pizzas, cakes, cars et cetera (plus the parser example from the GoF book).
能否请您告诉我有关此Patten的一些用法在现实世界中的应用程序/ API中,最好是C ++ 、. NET或PHP(因为我熟悉的是这些语言)。
Could you please tell me about some usages of this patten in real-world applications/APIs, preferably from the world of C++, .NET or PHP (as those are the languages I'm familiar with).
谢谢。 / p>
Thanks.
推荐答案
更新:我最近遇到了一个更好的示例(imo)。检出Quartz调度程序包中的JobBuilder和TriggerBuilder实现:
Update: I recently came across an even better example (imo). Checkout the JobBuilder and TriggerBuilder implementations in the Quartz scheduler package: http://quartz-scheduler.org/api/2.1.5/
此外,当我有时间的时候,只是为了娱乐/练习,我尝试用Java编写所有GoF模式的示例。就在最近,我使用了Builder模式使生成不同类型的站点地图(Google站点地图与html站点地图等)变得容易。该代码在Java中,但您可能会有用:
Also, when I have time, just for fun/practice, I try to write examples of all GoF patterns in java. Just recently, I used the Builder pattern to make it easy to generate different types of Sitemaps (google site map vs, html site map, etc). The code is in java, but you might be useful: https://github.com/dparoulek/java-koans/tree/master/src/main/java/com/upgradingdave/koans/builder
很好的问题,我也想看看更多现代示例。
Good question, I'd be interested in seeing more modern examples too.
这篇关于Builder模式的真实示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!