Beta
Abstract Model Magic
28 of 31nrgarg
Loading description...
Functional Programming
Refactoring
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
( JS )
Error message for failing
Magic.proto.register instanceof Function
assumes it does not exist. There are other reasons this test could fail.Same for
instance.name
.( JS )
Testing for prototype methods depends on them being enumerable. It also does not actually test
register
is the only one.( JS, possibly others )
Example tests would be nice.
Needs random tests.
Do you actually need the
register
method for this task anyway? It can be easily done inside theMagicModel
constructor.It's worded in extremely confusing way and lacks unit tests.
Can you specify what was confusing about the details?
Also - what cases do you think should be covered for the unit tests (that haven't been already)?
Well, ruby unit test box is empty, and description doesn't say if it's supposed to have setters, if attributes can be added outside initializer etc.
The "no attributes holding data, no instance variables being passed around" part is also somewhat confusing. Is it expecting
#methods #responds_to?
etc. to work or just#name
etc.Hm, how bout one more test case then?
Since :name and :initialize are Object methods, we check to make sure :register is the only method that exists on the instance.
With regards to the instance variables part - the idea is that you don't use attr_accessor or explicitly define the name method and use an instance variable to pass around the initialized name value
i.e.
And there is a test to make sure that there are no instance variables initialized.
Well, test it explicitly if that's requirement, preferably in unit test box too.
The method assertion is now in. The instance variable test was already there though.
Man this kata was confusing... You leave a whole ton of stuff out, and add some things which are just wrong/confusingly worded.
register
,get
, andset
should do, and what arguments they should expect, should be stated somewhere.init
object may be undefined, despite your note that the "object expects to be initialized with the name property".var self = this;
is necessary for it to work.register
,get
, andset
methods.I hope these don't sound too harsh; I just became very frustrated with this kata, writing elaborate methods to avoid adding anything to the instance, then failing miserably, slowly coming round to the fact that I understood pretty much 1% of the description overall.
I hope these suggestions will be helpful, at least for others to see if they get stuck.
Nope - definitely open to criticism. It's the first kata I've ever written and definitely needs polishing.
I've updated the boilerplate code and removed all of the self references. That was more of a personal coding style that was bleeding in to the end result - not exactly something I need to impose.
I've updated the description to elaborate on the tasks at hand and how each prototype method works.
Updating the test cases to actually test those prototype methods...Yeah I can't believe I skipped that entirely. On it :)
Also, I love your solution. This is basically the reason why I love this site :). Essentially, the getter and setter methods are obsolete. Since real work is happening in the "register" method, should I just remove the dependency on get and set ?
This comment has been hidden.