This page is no longer maintained — Please continue to the home page at www.scala-lang.org

patterns like multiton for stdlib?

1 reply
wookietreiber
Joined: 2011-04-24,
User offline. Last seen 42 years 45 weeks ago.

Greetings debaters,

I recently tried to pull-request a multiton trait to stdlib @ github [0]
(you can also find the trait enclosed), which has been rejected with the
comment that it "should be directed toward an external library".

I imagine, everyone would like the standard library to contain
implementations of common patterns, to reduce the fuss to get that pattern
on the classpath and therefore make programming easier for everyone.
Unfortunately, there is no clear definition of "common" and it is unclear,
whether a pattern, like the multiton pattern [1], should find a home in
scala's stdlib or not.

I guess, a good question is: what are the criteria for a pattern to be in
the standard library?

- general enough? (as in: is the pattern general enough, to be in a
general purpose programming language / stdlib of that language?)
- usefulness (How does one define usefulness? enough ppl wanting it?)
- usefulness compared to paradigms of the language (pattern vs anti-pattern)
- references in literature? (as in: the pattern has been (academically)
suggested to be a (good) solution for a common problem)

Is there a guideline for contributers on that topic? If not, I think,
there should be.

What are your opinions on the topic in general and in special about
trait Multiton[A,B]?

Best regards
wookietreiber aka Christian Krause

P.S.: some notes on the multiton trait:
- I don't neccessarily think that it should be in package scala, I guess
package scala.util would maybe be a better choice
- on the abstract factory: currently `val create: A => B` but may also be
def create(a: A): B

[0] https://github.com/scala/scala/pull/82
[1] http://en.wikipedia.org/wiki/Multiton

Alec Zorab
Joined: 2010-05-18,
User offline. Last seen 42 years 45 weeks ago.
Re: patterns like multiton for stdlib?

Not in direct response to your questions (I have no idea!), but I'm
really struggling to think of a scenario where using your multiton
pattern isn't, pretty much by definition, an "anti-pattern" / "code
smell"; Incidentally, I feel a little dirty for using those terms in
the preceding sentence.

On Sun, Sep 11, 2011 at 1:07 PM, wookietreiber
wrote:
> Greetings debaters,
>
> I recently tried to pull-request a multiton trait to stdlib @ github [0]
> (you can also find the trait enclosed), which has been rejected with the
> comment that it "should be directed toward an external library".
>
> I imagine, everyone would like the standard library to contain
> implementations of common patterns, to reduce the fuss to get that pattern
> on the classpath and therefore make programming easier for everyone.
> Unfortunately, there is no clear definition of "common" and it is unclear,
> whether a pattern, like the multiton pattern [1], should find a home in
> scala's stdlib or not.
>
> I guess, a good question is: what are the criteria for a pattern to be in
> the standard library?
>
> - general enough? (as in: is the pattern general enough, to be in a
>  general purpose programming language / stdlib of that language?)
> - usefulness (How does one define usefulness? enough ppl wanting it?)
> - usefulness compared to paradigms of the language (pattern vs anti-pattern)
> - references in literature? (as in: the pattern has been (academically)
>  suggested to be a (good) solution for a common problem)
>
> Is there a guideline for contributers on that topic? If not, I think,
> there should be.
>
> What are your opinions on the topic in general and in special about
> trait Multiton[A,B]?
>
>
> Best regards
> wookietreiber aka Christian Krause
>
>
> P.S.: some notes on the multiton trait:
> - I don't neccessarily think that it should be in package scala, I guess
>  package scala.util would maybe be a better choice
> - on the abstract factory: currently `val create: A => B` but may also be
>  def create(a: A): B
>
>
> [0] https://github.com/scala/scala/pull/82
> [1] http://en.wikipedia.org/wiki/Multiton
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland