Fluency icon indicating copy to clipboard operation
Fluency copied to clipboard

Fixed 2 methods in ARandom to return more appropriate values

Open joshua-peterson-volusion opened this issue 12 years ago • 4 comments

Fixed ARandom.Int to actually return a normal int. Fixed ARandom.String to include the entire alphabet.

What would you think about ARandom.Int returning only from 0 to int.MaxValue? I think most existing code that would break would be due to negative numbers, not overly large ones. Just like ARandom.String doesn't return all possible chars, ARandom.Int doesn't return all possible ints. It's the most common ones (positive). I think it makes sense to only return negative numbers when the programmer explicitly requests them. Thoughts?

ChrisEdwards avatar Aug 06 '13 04:08 ChrisEdwards

What if ARandom.Int takes some args, a min and max number? that way if you want negative numbers you can have them

On Mon, Aug 5, 2013 at 11:44 PM, Chris Edwards [email protected]:

What would you think about ARandom.Int returning only from 0 to int.MaxValue? I think most existing code that would break would be due to negative numbers, not overly large ones. Just like ARandom.String doesn't return all possible chars, ARandom.Int doesn't return all possible ints. It's the most common ones (positive). I think it makes sense to only return negative numbers when the programmer explicitly requests them. Thoughts?

— Reply to this email directly or view it on GitHubhttps://github.com/ChrisEdwards/Fluency/pull/8#issuecomment-22158091 .

jamessmckay avatar Aug 06 '13 12:08 jamessmckay

There's a method called ARandom.IntBetween(x,y) that does that already.

On Tue, Aug 6, 2013 at 7:35 AM, jamessmckay [email protected]:

What if ARandom.Int takes some args, a min and max number? that way if you want negative numbers you can have them

On Mon, Aug 5, 2013 at 11:44 PM, Chris Edwards [email protected]:

What would you think about ARandom.Int returning only from 0 to int.MaxValue? I think most existing code that would break would be due to negative numbers, not overly large ones. Just like ARandom.String doesn't return all possible chars, ARandom.Int doesn't return all possible ints. It's the most common ones (positive). I think it makes sense to only return negative numbers when the programmer explicitly requests them. Thoughts?

— Reply to this email directly or view it on GitHub< https://github.com/ChrisEdwards/Fluency/pull/8#issuecomment-22158091> .

— Reply to this email directly or view it on GitHubhttps://github.com/ChrisEdwards/Fluency/pull/8#issuecomment-22175506 .

Chris Edwards

"Whatever you do, work at it with all your heart, as working for the Lord, not for men"

  • Col 3:23

ChrisEdwards avatar Aug 09 '13 04:08 ChrisEdwards

I would disagree with that. If I ask for ARandom.Int, I expect a random int. I would completely support 2 additional methods, ARandom.PositiveInt and ARandom.NegativeInt.

I would be less worried about the people that are (wrongly) expecting only positive number and more worried about those that think they are testing against the entire spectrum of ints and are only using a very small subset of ints.

From: Chris Edwards [mailto:[email protected]] Sent: Monday, August 5, 2013 11:45 PM To: ChrisEdwards/Fluency Cc: Joshua Peterson Subject: Re: [Fluency] Fixed 2 methods in ARandom to return more appropriate values (#8)

What would you think about ARandom.Int returning only from 0 to int.MaxValue? I think most existing code that would break would be due to negative numbers, not overly large ones. Just like ARandom.String doesn't return all possible chars, ARandom.Int doesn't return all possible ints. It's the most common ones (positive). I think it makes sense to only return negative numbers when the programmer explicitly requests them. Thoughts?

— Reply to this email directly or view it on GitHubhttps://github.com/ChrisEdwards/Fluency/pull/8#issuecomment-22158091.