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

In docs, "valueA" and "valueB" should have more descriptive names #4

Open
markstos opened this issue Nov 3, 2014 · 2 comments
Open

Comments

@markstos
Copy link

markstos commented Nov 3, 2014

I tried using this diff tool, following the example, like this:

 var str = formatter.getStyledDiff(old, new);

The output surprisingly put the "-" sign next to next to the "new" data structure and the "+" sign next to the "old" data structure, which is reverse of what one would expect with the arguments above. I suspect what you intended was more like this:

var str = formatter.getStyledDiff(got, expected);

With these semantics, the "new" value comes first, while the old value comes second. With clear names for the first and second arguments, it becomes clear which argument should have the "-" next to it in the output and which should have the "+".

If "old vs new" semantics were intended, then you should reverse the code accordingly if "got vsexpected" semantics were intended, the docs should be updated to replace valueA and valueB with "got" and "expected" instead.

@markstos
Copy link
Author

markstos commented Nov 3, 2014

This is interesting. objectDiff is currently also using undescriptive names of objectA and objectB, but they intend "old vs new" semantics".

unfunk-diff uses "valueA" and "valueB" in the example. It looks the same, but I see from your source code that you intend "actual vs expected" semantics and reverse the order of the arguments. All the more reason to be clear!

Bartvds added a commit that referenced this issue Nov 10, 2014
@Bartvds
Copy link
Owner

Bartvds commented Nov 10, 2014

Nice analysis, you're right about the actual/expected as this module was extracted from a test formatter.

The language is now improved in the readme.

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