7 kyu

Factory Functions #2 - Inheritance and Object Composition

380 of 382donaldsebleung
Description
Loading description...
Fundamentals
Tutorials
Object-oriented Programming
  • Please sign in or sign up to leave a comment.
  • user8436785 Avatar
  • user8436785 Avatar

    married = Test.randomToken() > 50;

    That will always be false -- randomToken generates a string and is never 50 characters. I think you meant Test.randomNumber() > 50?

  • wthit56 Avatar

    Works well.

    A couple of changes I'd suggest to the description:

    There was no mention of the need for "inheritance" in the description. You describe how such inheritance would work, but you should say the construction worker object should inherit from person to make sure they get the point.

    "My boss is called BOSS_NAME and is a very nice person!" --BOSS_NAME is a tad confusing. People can figure it out, but it could be clearer.

    • donaldsebleung Avatar

      A couple of changes I'd suggest to the description

      Since you worded it that way, perhaps you should've raised this as a "Suggestion" instead of an "Issue". An "Issue" suggests that there is something that requires fixing in order for the Kata to be completable or of acceptable quality.

      There was no mention of the need for "inheritance" in the description. You describe how such inheritance would work, but you should say the construction worker object should inherit from person to make sure they get the point.

      I've updated the Description to state explicitly that the constructionWorker function should "inherit" from the person function as demonstrated in the Overview; hope this clarifies the Task.

      "My boss is called BOSS_NAME and is a very nice person!" --BOSS_NAME is a tad confusing. People can figure it out, but it could be clearer.

      I assumed that the average solver would immediately recognise BOSS_NAME as a placeholder and not a literal part of the string but anyway, I updated the Description to make it even more explicit and eliminate any possible source of ambiguity.

      Thanks for your input though, constructive feedback is always welcome :D

      Issue marked resolved by donaldsebleung 8 years ago
    • wthit56 Avatar

      Yeah, that's fair. I wasn't sure what category to put it in... I've been going through your in-Beta katas, trying them out, and seeing if anything could be added for completeness or if I could just approve them. That's why I chose "issue," as it was the only thing stopping me from approving it.

      But yeah, either way... ;P

  • kazk Avatar

    This comment has been hidden.

  • matt c Avatar

    Shouldn't the person class use a capital P?

    • donaldsebleung Avatar

      Yes, except if you read the description properly you would realize that person is just an ordinary object-returning function, not a class.

      The whole point of this Kata series is to instantiate objects without classes.

      Question marked resolved by donaldsebleung 9 years ago
    • matt c Avatar

      in the example Animal has a capital A...? and I don't see a difference between the Animal function in the example and the person function we use here...

    • donaldsebleung Avatar

      I see, well spotted :) It doesn't really matter, it's just convention.

      Since person is just an ordinary function, I thought I would stick to lowerCamelCase (the default convention in Javascript).

    • matt c Avatar

      I think it's more best practice but I'm not 100% sure... it shouldn't matter too much I guess

    • matt c Avatar

      actually I would refer to the codex for best practices. codex