jgamble/Algorithm-Networksort

Change To Object-Oriented Code

Closed this issue · 5 comments

Much of the code would be simplified if the network was changed into an object, particularly the code that counts comparisons and comparators-in-parallel.

Nearly there. I've decided that I need a function returning the object though, as even with cut-and-paste the construct Algorithm::Networksort->new() is just a bit too much text.

Math::Complex has a cplx() function that returns the Math::Complex object. I am open to suggestions for an equivalent function that doesn't have more than, say, six characters in its name.

nwsrt() perhaps? Fairly safe since the 'nw_' prefixes are being removed from the formerly exported function names.

It's not complete -- documentation isn't done, the Best module could be better integrated, and the graph code probably belongs in a separate module -- but it is object-oriented.

I'm about to go to sleep now, and assuming I don't find anything truly bad about it, I'll merge the code later today into master. With that done, the other issues can be worked on without my worrying about massive re-basing.

And done, after updating Build.PL.

Cool, looking good! Just curious: why did you switch to Moose instead of Moo? I was under the impression Moo was preferred unless you need some of the advanced meta-object stuff...

In theory, yeah. But I was having issues with Moo's lack of typing (I have arrayrefs of arrayrefs going on there), and since Moo's solution was to add more modules, I didn't see the point in upping the complexity when Moose had the complexity built-in without my having to second-guess the the system -- the documentation for the helper modules was not what I'd call comprehensive.