Better HN
topnewbestaskshowjobs
Log inSign up

dan_83

1 karma · joined Jul 7, 2022 (4y ago) · 1 submissions

Submissions

comment 4y ago · link · parent

Looks like a perfect case for a builder pattern, that way you can support sensible defaults in just about every language.

default_pizza() .with_crust(Crust::Cheesy) .with_sauce(Sauce::Garlic) .add_topping(Topping::ExtraCheese) .cook()

I'm not going to weigh in on the DRY stuff because it's being discussed to death. I just liked thinking about how I would approach this problem.