-2

I was very impressed by the policy based design described in Modern C++ Design by Andrei Alexandrescu and tried it successfully in some light weight programs. Now I have to write a real world system in Python and I think that approach would be very useful here. However, I can't find a single example of this approach in Python. Is it not recommended in Python or are there better alternatives? Can someone point me to an example of policy based design in Python? My aim is to develop an auctioning system and I want to be able to choose the auction strategy - English, Dutch, Silent, etc - at run time.

Since Python and Ruby are so similar, I guess an example in Ruby will also do.

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
341008
  • 9,862
  • 11
  • 52
  • 84
  • 2
    What's the question here? It might also help if you provide information about, or links to information about, "policy based design". – Marcin Oct 23 '14 at 16:43
  • @Marcin I have already asked if policy-based design is recommended in Python or if there are better alternatives? I have now added another one - "point me to an example of policy based design in Python". And I have specified that I am talking about the "policy based design" as described in "Modern C++ Design". Which part would you like me to elaborate on? – 341008 Oct 23 '14 at 16:53
  • 2
    You should maybe continue reading my comment past its first sentence. Just because something has the linguistic structure of a question, it does not follow that it actually represents a sensible question. – Marcin Oct 23 '14 at 16:55
  • 3
    I suspect that most users on this site don't own the book "Modern C++ Design", so you're not likely to get an answer unless you can describe it well enough to people that haven't read it before. – Kevin Oct 23 '14 at 16:55
  • 2
    If your question is whether it's recommended, it's off-topic because it's primarily opinion-based. If you want to be pointed to examples, it's off-topic because it's asking about off-site resources. See [Help Center: On-Topic](http://stackoverflow.com/help/on-topic) – Lukas Graf Oct 23 '14 at 16:59

1 Answers1

-1

My aim is to develop an auctioning system and I want to be able to choose the auction strategy - English, Dutch, Silent, etc - at run time.

You could just use strategy pattern (also known as the policy pattern) to accomplish exactly this.

You could also use mixins to provide the strategy instead of composition.

Marcin
  • 48,559
  • 18
  • 128
  • 201