Skip to content

custom-set: add to track - #206

Merged
matthewmorgan merged 4 commits into
exercism:masterfrom
javaeeeee:custom-set
Dec 21, 2016
Merged

matthewmorgan merged 4 commits into
exercism:masterfrom
javaeeeee:custom-set

Conversation

@javaeeeee

Copy link
Copy Markdown
Contributor

dibs: I will implement custom-set

@matthewmorgan

matthewmorgan commented Dec 17, 2016 •

Copy link
Copy Markdown
Contributor

@javaeeeee you have been contributing so much lately, thank you! Sorry that it's taken so long to get to these pull requests, but I wanted to give them proper attention.

I have to challenge the implementation of this contribution, and ask the following question: Do you think there might be a better way to do this? Or do you feel this implementation makes sense the way it is?

Let me explain: one of the core features of the Java language is the ability to apply object-oriented principles, like extending base classes. Your CustomSet class uses a Java Set for storage under the hood, and provides methods such is isEmpty by simply returning set.isEmpty().

I would suggest that one of two approaches might provide a better lesson for students of Java on Exercism:

  1. Use the base Set class by extending it to define CustomSet. Add or override only the methods required to meet the spec.
  2. Go 'closer to the metal.' Don't use Set at all. Instead create an Element class (or some name of your choosing) that implements hashCode and equals(), and implements Set behaviors without leveraging any class from the Java Collections library.

What do you think about one of those two approaches?

@jtigger jtigger changed the title dibs: I will implement custom-set custom-set: add to track Dec 17, 2016
@javaeeeee

javaeeeee commented Dec 17, 2016 via email

Copy link
Copy Markdown
Contributor Author

@matthewmorgan

Copy link
Copy Markdown
Contributor

@javaeeeee I completely respect your decision to use composition over inheritance. Thank you for your explanation!

@matthewmorgan
matthewmorgan merged commit 6d8ec4f into exercism:master Dec 21, 2016
@javaeeeee

javaeeeee commented Dec 21, 2016 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants