14

If you do this, please, don't have children.

P.D. count the number of *if*s

Comments
  • 3
    I can't see a fancy way to remove them, although I nejther do a lot of JS nor any angularjs.
    Whats wrong with it?
  • 0
    @ComradeBob for starters the first if prevents you from Subscribing to the observable, the "avoid undefined" logic could go in a set method, and tbh it also looks ulgy as hell
  • 1
    My God, there are so many ways to make this cleaner. It's really bothering me.
  • 1
    Oh the voting options are fibonacci numbers
  • 1
    I noticed that often when I need too much ifs, using a finite state machine can be a better solution. Of course this doesn't apply to all problems.
  • 1
    Why doesn't the ppGame do it's own initialisation.

    Why do those arrays need creating outside of the ppGame in the first place? So many if statements could just be removed by giving the ppGame a constructor that does all that.

    Please please use empty arrays to mean no results. Not null/undefined. That way you can treat it uniformly everywhere.
Add Comment