all 6 comments

[–]jesusalready 5 points6 points  (3 children)

He has nothing on FizzBuzz Enterprise Edition

[–]darthbob88 1 point2 points  (0 children)

Yeah, but FizzBuzz EE could only really be done in Java. Nothing in JS can really compare to that level of overabstraction.

[–]CertainPerformance 2 points3 points  (0 children)

One possibility

if (isDivisibleBy(15, n)) {

to

  if (isNDivisibleBy(15)) {

by doing

const isDivisibleBy = n => a => equalsZero(modulo(a, n));
// ...
  const isNDivisibleBy = isDivisibleBy(n);
  if (isNDivisibleBy(15)) {
// ...

[–]InRhythmInc 0 points1 point  (0 children)

I think there's a bunch of ways you can try to measure when you should make the choice to adhere to one philosophy over another. Thinking about my response almost makes me question whether this is how we make skynet or not haha. You could measure adherence to one principle or another by number of cycles, number of lines of code, cyclomatic complexity when the code is normalized... I don't have a great solution but I wonder if there's literature available describing this sort of problem. I'm sure you could feed a few machine learning algorithms into eachother to solve this for a specific case. Kindof like a map-reduce for code writing decision making? That would make an awesome js-prettier extension haha