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

Make api application consistency ... So Locale would become Locale() #22

Closed
mdmoura opened this issue Mar 22, 2016 · 2 comments
Closed

Comments

@mdmoura
Copy link

mdmoura commented Mar 22, 2016

Hello,

I was checking the following:

.RuleFor(x => x.Locale, y => y.Address.Locale)
.RuleFor(x => x.Latitude, y => y.Address.Latitude())

I think that, for consistency, a method should always be used, e.g., Locale()

And this could be an extending point of Bogus ... For example:

public static Locale(this IValueResolver resolver) {

}

So all API options would be an extension of an "IValueResolver" ...

Having, for example, a Hacker property in Faker class seems kind of strange ... Maybe it should be an extension or maybe Faker could be a partial class to allow adding more properties as a way to extending it ... Well, not sure if this is the best option. Just an idea ...

Thanks,
Miguel

@bchavez
Copy link
Owner

bchavez commented Mar 23, 2016

Hi Miguel,

The Faker class is meant to be used by Faker<T> as a Facade over the data sets imported from faker.js. This is why most of the y.DataSet are defined as properties. The methods on data sets such as y.DataSet.Method() has a direct counterpart to a faker.js JavaScript method. I would like very much to keep these APIs consistent with faker.js as much as possible.

With this in mind, y.Address.Localeis a property value on a DataSet and is a Bogus/C# concept. Additionally, y.Address.Locale() method isn't found on faker.js:Address.Locale(). I hope this explains some API design decisions.

@mdmoura
Copy link
Author

mdmoura commented Mar 23, 2016

Hi,

Yes, it makes sense now that you explain the faker.js part.

Thanks

@mdmoura mdmoura closed this as completed Mar 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants