algorithm-archive icon indicating copy to clipboard operation
algorithm-archive copied to clipboard

Unifying algorithms and examples (code)

Open PudottaPommin opened this issue 6 years ago • 3 comments

Hey,

when I was looking through code examples, I noticed, each implementation is different from each other. Which is expected in some way. But we should try to unify things like:

  • input values
  • printed output
  • naming of functions - where possible

When you change from one language to another, it's sometimes hard to understand what that algorithm does.

Example: Monte Carlo Java implemented everything as static functions with sample size 1000. JS is functions, which is fine (JS versioning is different topic) with sample size 100000000. Swift is mix of objects/functions (can't say if good/bad, I don't know Swift) with sample size 10000. @julianschacher is making C# implentation which uses OOP and looks good. So it could be example for OOP languages implementation.

You may agree with me or not, I can be wrong in this, but it's worth discussion.

PudottaPommin avatar Aug 01 '18 09:08 PudottaPommin

I thought we were generally trying to keep the implementations as consistent as we can; however, small things (like the number of points in MC) are easy to slip through the cracks. This is a good point to bring up, though and we should definitely see which implementations are not consistent enough.

leios avatar Aug 01 '18 09:08 leios

I don't really mind if things like sample size is different, what I care about are the algorithms. Function names are a bit more important, but they will have to be different to some extent because of different styles guides. OOP versus functions is better left up to the author and reviewers, in my opinion.

If we want to unify input, then we should go all the way and impose a set of tests with edge cases and stuff. I suspect many implementations are a little too lax. This might be a pain in the ass to implement though

jiegillet avatar Aug 01 '18 11:08 jiegillet

Yes, we have to leave differences in languages aside, because that's something we can not change. And yes, this thing is a lot of work, because there is quite a few algorithms with many implementations. I'm not sure about those tests, how you think they should look or be implemented.

About inputs, they should be same as are in algorithm explanation (if there is some) ie. C example for matrix in GE

PudottaPommin avatar Aug 02 '18 11:08 PudottaPommin