Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Petition to undeprecate random primitives #607

Closed
AustinGil opened this issue Mar 9, 2022 · 8 comments
Closed

Petition to undeprecate random primitives #607

AustinGil opened this issue Mar 9, 2022 · 8 comments
Labels
c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs help wanted Extra attention is needed p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug

Comments

@AustinGil
Copy link

In an older version, many of the methods on faker.random that return primitive values were deprecated and moved to faker.datatype. I never understood the reason, and I'd argue that restoring them is better developer experience.

  • When trying to generate a random value (ie Number), it's more intuitive to go to faker.random
  • Using random is better for intellisense because faker.datatype clashes with faker.database. It's much nicer to just type "faker.r" then tab.
  • It feels to me like faker.random and faker.datatype serve the same purpose of grabbing fake primitives.

I'm bringing some of my own bias and assumptions here, so I reserve the right to be totally wrong, but I thought I would mention it in the spirit of trying to make this library better.

@AustinGil AustinGil added the s: pending triage Pending Triage label Mar 9, 2022
@ejcheng ejcheng added s: needs decision Needs team/maintainer decision and removed s: pending triage Pending Triage labels Mar 9, 2022
@ST-DDT
Copy link
Member

ST-DDT commented Mar 9, 2022

FFR: This was added in 7ad22c2 v5.5.0

The actual issue is lost to time.

Currently the helper, random and datatype modules are kind of ambiguous.
So I consider removing datatype to be a viable solution, not sure what the other maintainers think though.

@ST-DDT
Copy link
Member

ST-DDT commented Mar 9, 2022

I found the original content in this event history: Marak/faker.js - Github Event History

Unfortunately, it does not contain a specific reason for that change.

@ST-DDT
Copy link
Member

ST-DDT commented Apr 8, 2022

We created a discussion on how to improve on this: #805

@ST-DDT ST-DDT added help wanted Extra attention is needed p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug and removed s: needs decision Needs team/maintainer decision labels Apr 8, 2022
@Shinigami92 Shinigami92 moved this to Todo in Faker Roadmap Apr 8, 2022
@Shinigami92 Shinigami92 added this to the v7 - Next Major milestone Apr 8, 2022
@ST-DDT ST-DDT added the c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs label Apr 8, 2022
@Shinigami92
Copy link
Member

When we bring stuff from datatype back to random, I think we should use new names like:

  • datatype.number => random.int (or random.nextInt? This would align with some other languages like Java 🤔)
  • datatype.float => random.number

@ST-DDT
Copy link
Member

ST-DDT commented May 3, 2022

I think moving it to individual modules (strings/numbers) might provide a better developer experience, because first you select what you want and then you have all the variations available for use.

@Shinigami92
Copy link
Member

I think moving it to individual modules (strings/numbers) might provide a better developer experience, because first you select what you want and then you have all the variations available for use.

Where would you put boolean, hex, datetime and uuid?
I think functions like array and json can be removed because I don't know which use-case they fulfill 🤷

@ST-DDT
Copy link
Member

ST-DDT commented May 3, 2022

  • Datetime delete
  • uuid -> string
  • hex -> string
  • boolean can remain in random or helpers
  • array and json/object/record should be modified and may be moved to helpers: array( numOrRange, elemSource()), ...

@pkuczynski
Copy link
Member

I can see the discussion going on here and in #805 - this is a bit confusing. Maybe we should close this issue and focus on the discussion only, which should then be spit into smaller issues?

Repository owner moved this from Todo to Done in Faker Roadmap May 5, 2022
@ST-DDT ST-DDT removed this from Faker Roadmap Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs help wanted Extra attention is needed p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
None yet
Development

No branches or pull requests

5 participants