question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dnd-character: Suggestions for improving constructor in stub and in reference solution

See original GitHub issue

Mayur on Slack said that the DND Character exercise was hard to figure out.

I suspect that adding a constructor to the stub file would improve the situation.

As for the modifier method, shouldn’t this be a static method?

And as for the reference solution, I would suggest the improvement to have Random dependency-injected into the constructor, since otherwise you can only do probabilistic testing, as is done now.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
sshinecommented, May 3, 2019

Regarding the modifier method, why would you declare this method static?

Because it depends on only its input, not on any object properties.

Since you don’t need the context of an object to compute the function, the minimal implementation would be a static method.

Compare this to the Haskell solution, the C# solution and the Python solution where they’re respectively a pure function independent of the Character type, a static method, and a top-level definition independent of the Character class. The closest of these to the Java track would be the C# one, I think.

0reactions
sshinecommented, May 3, 2019

I don’t think we should be pushing users towards a certain solution.

OK. I’m not sure I can imagine more than one solution besides the one where Random is injected into the constructor. The unit tests aren’t compatible with this type of solution, and I can’t imagine how it could be.

I believe I’ve left enough of an impression without contributing code to the solution, so I’ll bid you a good day now. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stub - D&D Wiki
Almost no class page is in a finished state when it is first posted. For guidance, see the 5e Class Design Guide. Aefling...
Read more >
Community solutions for D&D Character in JavaScript on ...
Explore other people's solutions to D&D Character in JavaScript, and learn how others have solved the exercise.
Read more >
Enforce super call on non constructor methods - java
No, that is not possible. It is entirely up to the overriding method to call the superclass method, or not. However, there is...
Read more >
D&D 5E Character Creation Guide - YouTube
A Dungeons and Dragons 5th Edition character creation tutorial.Sponsored by Hero Forge: http://bit.ly/heroforge1Support WASD20 on Patreon: ...
Read more >
5 EASY Roleplaying Tips for a Better D&D 5e Character
Want to learn how to roleplay better for your next DnD character ? Whether you've been playing Dungeons and Dragons for years, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found