Q:

Seeding a PRNG - Custom Setter

I have a PRNG-Class called Generator. Now, after creating a new instance of it:
var g:Generator = new Generator();

Custom function: set_seed()  -  Please review this approach.
I call g.set_seed(); which has the following logic:
public function set_seed(s:Number = 0):void
{
    seed = (s > 0) ? s : new Date().getTime();
}

Pro: I can call it without any arguments, looks more beautiful in the classes I'm using it.
Con: set_seed looks awful and I feel I should be using Flash's Getter/Setter approach.

(I'm getting the seed with: get_seed();)

A:

I would expect the generator to seed itself (using the current time) in its constructor.
Therefore, I would not use a default parameter in your set_seed method.
Also, in your current code, you treat all the negative values the same as zero. I wouldn't recommend that. Many random seeders can handle negative seeds as well, if you don't want to do that: Throw an Exception/Error!
Therefore, I would use this:
public function set_seed(s: Number): void
{
    if (s < 0) {
        throw new Error("Seed must be positive");
    }
    seed = s;
}

For comparison and inspiration, check Java's java.util.Random class. Note that it has two constructors available, one for initializing to System's seed and one for initializing to a specific seed. That is an approach I would recommend.

