Real-world examples of the Builder pattern

后端 未结 3 1871
孤独总比滥情好
孤独总比滥情好 2021-02-04 06:21

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

3条回答
  •  隐瞒了意图╮
    2021-02-04 06:30

    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/

    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.

提交回复
热议问题