Ad
  • Custom User Avatar
    SUPER:
    function baseClass(config){
      this.config = config;
      this.setConfig = function(value){};
    }
    
    MIXIN:
    function observableMixin(){
      this.listeners = {};
      this.addListener = function(name, callback){
        if(!this.listeners[name]) this.listeners[name] = [];
        this.listeners[name].push(callback);
      }
      this.removeListener = function(name, callback){
        this.listeners[name] = this.listeners[name].filter(
          function(fn){ 
            return fn != callback;
            });
      }
    }
    
    TypeError: c.hasListener is not a function
        at it
        at begin
        at it
        at describe
        at /runner/frameworks/javascript/cw-2.js:152:11
        at Promise._execute
        at Promise._resolveFromExecutor
        at new Promise
        at describe
        at /home/codewarrior/index.js:49:5
        at /home/codewarrior/index.js:96:5
        at Object.handleError
    

    There's no hasListener method anywhere, and no explanation of what the tests are trying to do - how am I even supposed to debug this?

    Edit: turns out there's a observableMixin.prototype.hasListener method, but again, if your solution is wrong and doesn't add this method to the created class, you will likely not be able to tell what's wrong.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Thanks for sugestions. I modified the description to be more omogen.
    Thanks :)

  • Default User Avatar

    I'd recommend adding some example code in the description. Show how you expect the extend function to be invoked, with or without mixin and scope.

    Also, the function's argument names in the description doesn't match up with the argument names in the solution setup:

    extend('ChildClass', BaseClass, EventDispatcher, scope);
    function extend(className, superClass, mixin, scope)
    

    You should change one or both so that the argument names are consistent. The latter names are clearer IMHO.

    Then, change your bullet list so that it has a bullet item for each argument, describing the type (string, function, object), what it represents, and identifying the arguments which were optional.

  • Default User Avatar

    What else should I improve in this kata? :)

  • Default User Avatar

    I implemented the wikipedia described approach and still remained confused :)

  • Default User Avatar

    Hm, my solution is passing randomly, probably is not really correct :D

  • Default User Avatar

    Is the recursive solution bad? I see the others had a different approach.

  • Default User Avatar

    Oh I see. I 'll try harder 3:)

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Hmm "Bit count of 16777216 should be 1" test said.

  • Default User Avatar

    Oh I see! Thank you for clearing that out for me :)

    I am sure you can remedy it :D

  • Default User Avatar

    As a last touch I have added tests for the mixin and specified it as being optional ;)

  • Default User Avatar

    Hey christianhammer,
    Congrats! you are the first one to solve it anyway :)
    The mixin was not declared as being optional so it is not tested for as being optional., where is the problem? :)
    My solution took care about the eventuality of providing some invalid value for the mixin by instinct :))

    However, I find the problem nice and pretty much easy to be solved but I see that people don't like it, so I will probably quit the idea :)

    Thanks for taking the time to solve and comment it!

  • Loading more items...